home *** CD-ROM | disk | FTP | other *** search
/ Merciful 1 / Merciful - Disc 1.iso / software / d / devpak / devpac.txt next >
Encoding:
Text File  |  1995-10-14  |  180.4 KB  |  4,384 lines

  1.                           DEVPAC 2 
  2.  
  3.  
  4.  
  5. CHAPTER 1: INTRODUCTION
  6.  
  7. ALWAYS MAKE A BACK-UP
  8.         Before using Devpac AMIGA you should make a back-up copy of
  9. the original disk and put the original away in a safe place. It is not
  10. copy-protected to allow easy back-up and to avoid inconvenience. This
  11. disk may be backed up using the Workbench or any back-up utility.
  12.  
  13.         NOTE: The original DEVPAC master disk had a technical support
  14. serial registration number, but you wont get this!.
  15.  
  16. REGISTRATION CARD
  17.         Enclosed with the manual is a registration card (but not for
  18. you, and you also get a free 68000 Pocket Guide (£2.95 from any
  19. good bookshop.)
  20.  
  21. THE README FILE
  22.         As with all Hisoft products Devpac AMIGA is continually being
  23. improved and the latest details cannot be included in this manual
  24. may be found in the README.S file on the disk. If you are not already
  25. in th CLI you should wait for any disk activity to stop. Press CTRL
  26. and both AMIGA keys (A software reset), insert your DEVPAC disk. Once
  27. in the CLI this file should be read by entering the command:
  28.  
  29. type readme (RETURN)
  30.  
  31. This display can be paused by holding down the menu button on the
  32. mouse.
  33.  
  34. INTRODUCTION TO THE CLI
  35.         Like most other programming developement tools, DeVPAC AMIGA
  36. is designed to be run from the CLI (Command Line Interface). If you
  37. examine the disk from the Workbench icon interface you won't see many
  38. icons on the disk because of this.
  39.         The CLI is deliberatly hidden from the average user, but as a
  40. programmer you will need to use it, although most of your developement
  41. time will be spent in th DEVPAC programs rather than the CLI.
  42.         DEVPAC disk one is a modified Workbench disk and to start with
  43. you should boot your machine as normal, with a kickstart disk if
  44. required, but when asked for workbench, insert DEVPAC disk one. If you
  45. have already booted from another disk, you should wait for all disk
  46. activity to stop, insert DEVPAC and preform a software reset.
  47.         The CLI is similar in concept to other non-iconic computers,
  48. such as those running MS-DOS or CP/m. It works by you entering
  49. commands such as:
  50.  
  51. dir (RETURN)
  52.  
  53. to get a directory of the disk. There is a full description on how to
  54. use the CLI and tutorial in the AMIGA user manuel.
  55.  
  56.         NOTE: If you have a non-UK keyboard, you may need to modify
  57. your s/startup-sequence file on your DEVPAC back-up disk, although
  58. this may have been done for you! See the readme for more details.
  59.  
  60. BACKUP DETAILS
  61.         Before making your security backups please ensure your master
  62. disks are write protected. It is recommended the backups made are
  63. regually virus checked with a reliable virus killer, or life could
  64. become very nasty!.
  65.  
  66. ONE-DRIVE SYSTEMS
  67.         Once you have booted the DEVPAC disk one enter the command
  68.  
  69. diskcopy df0: to df0: (RETURN)
  70.  
  71. Then follow the prompts given. The disk to copy from is our write-
  72. protected master disk one the disk to copy to should be a write-
  73. enabled blank disk. Then repeat the procedure with disk two.
  74.  
  75. TWO-DRIVE SYSTEMS
  76.         Enter the command:
  77.  
  78. diskcopy df0: to df1: (RETURN)
  79.  
  80. inset a write-enabled blank disk in the internal drive, and the write-
  81. protected DEVPAC disk one in the external drive and follow the prompts
  82. given. Repeat the procedure with disk two.
  83.  
  84. MAKING A WORK DISK
  85.         Although you now have a back-up, the disk as supplied dosen't
  86. have room on it for large programs, and it is best to make one or more
  87. work disks when you want to start serious programming. Exactly how you
  88. do this depends on your hardware confuguration.
  89.  
  90. ONE-DRIVE SYSTEMS
  91.         For single drive users it is best to get rid of as much as you
  92. can fron the DEVPAC disk. Prime candidates are all .info files
  93. together with the printer drivers and keymap files not required.
  94. Deleting Preferances will save space, but this may be useful.
  95.         If you follow these reccomendations the commands required (on
  96. another backup) would be:
  97.  
  98. cd df0: (RETURN)
  99. delete #?.info (RETURN)
  100. cd devs/printers (RETURN)
  101. dir (RETURN)
  102.  
  103. This will produce a list of printer drivers. Use the delete command to
  104. erase those you do not need.
  105.  
  106. cd devs/keymaps (RETURN)
  107. dir (RETURN)
  108.  
  109. This will produce a list of keymap files. Continue as above.
  110.  
  111. If space still bets tight you could start deleting the examples
  112. directory, seldom used include files and some commands in the c
  113. directory.
  114.  
  115. TWO-DRIVE SYSTEMS
  116.         Two drive owners are reccomended to keep the workbench disk
  117. free of all source code, and put such files together with the include
  118. files on the disk in th external drive. The commands to do this (using
  119. another back-up) would be:
  120.         (NOTE: The first command formats a blank disk in the  external
  121. drive losing all data. If you are using a pre-formatted disk you don't
  122. need to do this)
  123.  
  124. format drive df1: name "source" (RETURN)
  125.  
  126. Insert a blank disk in the external drive, then press (RETURN) to
  127. format it.
  128.  
  129. cd df0: (RETURN)
  130. makedir df1:include (RETURN)
  131. makedir df1:examples (RETURN)
  132. copy include to df1:include all (RETURN)
  133. copy examples to df1:examples all (RETURN)
  134. delete include all (RETURN)
  135. delete examples all (RETURN)
  136.  
  137.         The commands create directories on the external drive for the
  138. example programs and the include files, then delete them from the disk
  139. in the internal drive (which must, of course, be a back-up).
  140.  
  141.         You will now probably want to copy the program files from
  142. DEVPAC disk two to your workbench disk. To do this insert your back-up
  143. disk two of DEVPAC master disk in df1: and type:
  144.  
  145. copy df1:c to df0:c all (RETURN)
  146. cd df1: (RETURN)
  147.  
  148.         This final command changes the default directory to the
  149. external drive so you can edit source files there more easily. It is
  150. often worthwile to build such a command into your startup-sequence.
  151.  
  152. HARD DISK USERS
  153.         Hard disk users should firstly boot from the hard disk, and
  154. not the DEVPAC workbench disk. Having done this, the DEVPAC disk one
  155. should be placed in the internal drive and the following commands
  156. executed, to copy the programs onto the hard disk:
  157.  
  158. copy df0:c/genam2 to c: (RETURN)
  159. copy df0:c/monam2 to c: (RETURN)
  160. copy df0:c/genim2 to c: (RETURN)
  161.  
  162.         Next the two subdirectories should be copied, and this depends
  163. on your requiremants - for example, you may wish to make a seperate
  164. DEVPAC directory on your herd disk. Whatever you choose you will need
  165. to copy the whole of directories "include" and "examples". If you
  166. choose to have a seperate DEVPAC sub-directory the commands would be
  167. (assuming dh0: is the name of your hard disk):
  168.  
  169. makedir dh0:devpac (RETURN)
  170. copy df0:include to dh0:devpac all (RETURN)
  171. copy df0:examples to dh0:devpac all (RETURN)
  172.  
  173.         Note that if you put the example directory within another
  174. directory you will have to change the INCDIR directives at the
  175. beginning of them for correct assembly.
  176.  
  177.         You will also want to copy the following file from your DEVPAC
  178. disk two backup.
  179.  
  180. copy df0:c/blink to dh0:c
  181.  
  182.         It probably isn't worth copying the other files until you need
  183. them.
  184.  
  185. THE DEVELOPMENT CYCLE
  186.         The purpose of DEVPAC is to allow you to enter assembly
  187. language programs, assemble  them to machine-code and debug them if
  188. (or should that be 'when') they don't work. Depending on your
  189. application, you may also be using a linker to join together seperate
  190. modules, possibly with the output from a high level language compiler.
  191. Of course the faster the development cycle, the faster you can get
  192. your programs up and running and DEVPAC was designed to be as fast and
  193. powerful as possible. The link stage is optional, as is the Compile
  194. stage.
  195.  
  196. DEVPAC DISK CONTENTS
  197.         DEVPAC is supplied on two 3.5" disks, the first a standard
  198. Workbench 1.2 disk, configured to enter the CLI on boot, and the other
  199. contains additional files.
  200.  
  201. DISK 1
  202. Programs in c directory:
  203. GENAM2 - Screen editor and control program
  204. GENIM2 - Assembler
  205. MONAM2 - Debugger
  206.  
  207. Other files:
  208. LIBS/LIBFILE.MONAM - Binary file used by debugger
  209. LIBS/ARP.LIBRARY   - Additional library
  210. README             - Latest details about DEVPAC
  211.  
  212. Additional subdirectories:
  213. INCLUDE  - Contains files for accessing the operating system.
  214. EXAMPLES - The source code to various example programs.
  215.  
  216. DISK 2
  217. Programs in the c directory:
  218. BLINK     - PD linker
  219. CONVERTFD - FD file conversion utility
  220. CONVERTI  - Include file conversion utility
  221.  
  222. + some Workbench files for which there is insufficient room on disk
  223. one.
  224.  
  225. Text files:
  226. BLINK.DOC - Instructions for linker
  227.  
  228. Additional subdirectories:
  229. INCLUDE.CBM   - The original Commodore include files with comments
  230. INCLUDE.STRIP - The original Commodore include files without comments
  231. FD.FILES      - The original Commodore fd files. Includes which
  232.                 registers are used when calling libraries.
  233. LIBRARY       - Contains amiga.lib, debug.lib
  234. ARP           - Contains parts of Charlie Heaths AmigaDOS replacement
  235.                 project (ARP)
  236.  
  237. HOW TO USE THE MANUAL
  238.      This manual makes no attempt to teach 68000 assembly language
  239. programming or to detail the instruction set.  For the former, the
  240. bibliography  lists  suitable  books,  while for  the  latter  the
  241. supplied  Pocket  Guide is very useful.  The  Appendices  give  an
  242. overview of the technical aspects of the AMIGA but they are not
  243. intended as a complete technical description of the machine.
  244.      This manual is set out in five chapters, this introduction, a
  245. chapter on the screen editor,  a chapter on the macro assembler, a
  246. chapter on the debugger, then a chapter on the linker. In addition
  247. there  are  eight  Appendices  which  detail  various   additional
  248. information.  We suggest you use the manual in a way that  depends
  249. on what type of user you are:
  250.  
  251. DEVPAC VERSION 1 USERS
  252. Turn  to  Appendix  F and read the  section  describing  the  new
  253. features,  then  read the Reference section of Chapter 4  if  you
  254. intend  using MonAM, as it has changed considerably. You will then
  255. probably want to dip into the manual to read about the new features
  256. that interest you.
  257.  
  258. BEGINNERS
  259.      If you are a newcomer to assembly language then we  recommend
  260. that you read one of the books in the Bibliography alongside  this
  261. manual.
  262.      At  the end of this chapter there is a simple tutorial  which
  263. you should follow to familiarise yourself with the use of the main
  264. parts of the program suite.
  265.      Chapter  2  details  the editor and is  well  worth  reading,
  266. though much of Chapter 3,  detailing the assembler,  is liable  to
  267. mean  nothing  until you become  more  experienced.  The  Overview
  268. section  of  Chapter 4,  the debugger,  is  strongly  recommended,
  269. though Appendices can be left  for  a  while.
  270. Looking  at the supplied source code may be helpful.
  271.  
  272. EXPERIENCED USER
  273.      If you are experienced in the use of 68000 assembly  language
  274. but have not used DEVPAC before then here is a very quick way of
  275. assembling a source file:
  276.      Load GENAM2, Press Amiga-L and select your file which will
  277. load into the editor. Press Amiga-A and select the options which you
  278. require  - if generating executable code then click on the  Memory
  279. button  for  additional  speed.  Pressing RETURN  will  start  the
  280. assembler, which may be paused by pressing any key, RETURN resumes.
  281. Any assembly errors will be remembered and on return to the editor
  282. you  will  be placed on the first one.  Subsequent errors  may  be
  283. found by pressing Amiga-J.
  284.      To run your successfully-assembled program (if assembled  to
  285. memory ) press Amiga-X. If assembled to disk, leave the editor and
  286. run it from CLI.
  287.      As  a  quick  introduction  to  the  debugger  the  following
  288. tutorial is recommended.  If you have any problems please read the
  289. relevant section of the manual before contacting us for  technical
  290. support.
  291.  
  292. A VERY QUICK TUTORIAL
  293.      This  is a quick tutorial intended to let you see  how  quick
  294. and easy it is to edit, assemble and debug programs with DEVPAC.
  295.      In  this tutorial we are going to assemble and run  a  simple
  296. program,  which  contains two errors,  and debug it.  The  program
  297. itself  is  intended to print a message.
  298.      To  run this tutorial you must be in the CLI. If you are not you
  299. should wait for any disk activity to stip, eject all disks, press
  300. (CTRL) and both Amiga keys, and insert the backup of DEVPAC disk one.
  301. It is convenient if we make the current directory the one where our
  302. source program is, with the command:
  303.  
  304. cd examples (RETURN)
  305.  
  306. Next load the editor/assembler, by typing:
  307.  
  308. genam2 (RETURN)
  309.  
  310.         After a short delay the screen will show an empty window: to
  311. load  the  file you should move the mouse over the PROJECT menu and
  312. hold the right mouse button, and release it on LOAD. A file selector
  313. will then appear and the file we want is called DEMO.S. You should
  314. click on the name to load followed by OK.
  315.      When  the file has loaded the window will show the top  lines
  316. of the file.  If you want to have a quick look at the program  you
  317. may press (SHIFT)-(DOWNCURSOR) or (CTRL)-C to move to the next page.
  318.      With  most  shorter  programs  it is best  to  have  a  trial
  319. assembly  that doesn't produce a listing or binary file  to  check
  320. the syntax of the source and show up any typing errors and so  on.
  321. Move the mouse to the  Program menu and click on Assemble.
  322.      A dialogue box will appear, which should be left alone except
  323. the button near the bottom,  labelled NONE,  should be clicked on.
  324. Click on the Assemble button or press RETURN and the assembly will
  325. begin.
  326.      The   assembler  will  report  an  error,   instruction   not
  327. recognised, and pressing any key will return you to the editor. The
  328. cursor will be placed on the incorrect line and the error  message
  329. displayed in the status line.
  330.      The program line should be changed from MOV.L to MOVE.L so do
  331. this,  then  click on Assemble form the Program menu  again.  This
  332. time  click on the Memory button,  this means the program will  be
  333. assembled  into memory,  instead of onto disk.  This is very  much
  334. faster  and  allows you to try things out  immediately,  which  is
  335. exactly what we want.  Clicking on the Assemble button will  again
  336. assemble  it,  and after you press a key to return to  the  editor
  337. it's ready to run.
  338.      The  assembly  worked this time, but don't run it yet - you will
  339. probably get a software error task held message from the system and
  340. have to reboot the machine.
  341.      The  tool for finding bugs and checking programs is a debugger,
  342. so click on  Debug from the Program menu.  The debugger is described
  343. more fully later, but for now we just want to run the program from the
  344. debugger to 'catch' any problems and find out what causes them, so
  345. press (CTRL)-R.
  346.      After a brief delay the message Address Error will appear at the
  347. bottom  of the display, with the disassembly window showing the
  348. current instruction:
  349.  
  350. start        MOVE.L    dosname,a1
  351.  
  352.      This will cause an address error because location dosname is at
  353. an odd address which cannot be accessed with the MOVE.L instruction.
  354. There should be a hash sign before the dosname to put the address of
  355. dosname into the register a1. To return to the editor press (CTRL)-Q,
  356. to ensure that the program will be killed and press Y to terminate the
  357. program and the debugger. We can fix this bug in the source code.
  358.      Press (AMIGA)-T, to go to the top of the file, then click on Find
  359. from the Search menu.  We are going to find the errant instruction
  360. so enter:
  361.  
  362.              MOVE.L
  363.  
  364.      Then press Return to start the search. The first occurrence is
  365. the one we are looking for:
  366.  
  367. start        MOVE.L    dosname,a1
  368.  
  369.      Ahah! - this is the one, so add a hash to change it to
  370.  
  371. start        MOVE.L    #dosname,a1
  372.  
  373.      then assemble it again.  If you click on RUN from the Program
  374. menu you should see the message,  and pressing any key will return
  375. you to the editor.
  376.      Although  the  program  now works we  shall  use  MONAM2,  the
  377. debugger,  to trace through the program,  step by step. To do this
  378. click on Debug from the Program menu, and the debugger will appear
  379. with the message Breakpoint, showing your program.
  380.      There are various windows, the top one displaying the machine
  381. registers, the second a disassembly of the program, the third some
  382. other memory.
  383.      If you look at window 2, the disassembly window, you will see
  384. the current instruction, which in our case is:
  385.  
  386. start        MOVE.L    #dosname,a1
  387.  
  388.      As  the  debug was specified in the source code  any  symbols
  389. will appear in the debugger.
  390.      Let's check the area around dosname. Press (AMIGA)-3 and you
  391. should see the window 3's title inverted. Next press (AMIGA)-A and a
  392. dialogue box will appear, asking WINDOW START ADDRESS? - to this
  393. enter:
  394.  
  395. string
  396.  
  397.      (it  must  be  in lower-case) and  press  (RETURN).  This  will
  398. re-display  window 3 at the address,  showing the message in  both
  399. hex and ASCII.
  400.      To  execute  this MOVE instruction press  Ctrl-Z.  This  will
  401. execute the instruction then the screen will be updated to reflect
  402. the  new  values of the program counter and register  A1.  If  you
  403. press Ctrl-Z again the MOVEQ instruction will be executed and d0 will
  404. be modified. The next two instructions are the expansion of the
  405. CALLEXECOpenLibrary macro call. Use (CTRL)-z to single step the move
  406. to a6 instruction.
  407.  
  408.         Next we have:
  409.  
  410.         jsr     _LVOOpenLiberary(a6)
  411.  
  412.         This is the call to the exec liberary. All calls to the AMIGAs
  413. operating system have the same form. We don't want to single step this
  414. - we know that amigaDOS works. To treat this system call as one
  415. instruction use (CTRL)-T
  416.         Now single step the next (TST.L d0). D0 should be non-zero; so
  417. the Z flag won't be present in MONAM's register display area.
  418.         Now you can continue to press (CTRL)-z until you get to:
  419.  
  420.         jsr _LVOOutput(a6)
  421.  
  422.         This is the call to the DOS.liberary to find our output
  423. handle. Use (CTRL)-T to skip over this. Use (CTRL)-Z to continue
  424. single stepping until we get to:
  425.  
  426.         jsr     _LVOWrite(a6)
  427.  
  428.         This is the call that will actually write our string on the
  429. screen - lets make sure that the registers are set up correctly. d1
  430. should have the output handle that came back from the output call in
  431. d0. d2 should have the address of the message. If you look from d2 in
  432. the register display you will see the ASCII bytes of the string. Now
  433. use (CTRL)-T to skip over the Write call. To check that it worked
  434. press the V key, then press any other key to return to monam (being
  435. careful not ot activate any other windows meantime).
  436.         Now all that is left is our de-initialisation. You can use the
  437. (CTRL)-Z and (CTRL)-T commands to step through it as before.
  438.         The last instruction in the program is an RTS. Single stepping
  439. this will terminate Monam, for now, and return to the editor.
  440.  
  441. CHAPTER 2: SCREEN EDITOR
  442.  
  443. INTRODUCTION
  444.      To  enter  and assemble your programs you need an  editor  of
  445. some sort and an assembler. GenAM is our editor which loads and runs
  446. the assembler. Genim as required giving the appearance of a full
  447. screen editor and a fast, full specification assembler as one program.
  448. It  also allows  you  to run your assembled programs directly  from
  449. memory without  having  to quit the program or do a disk  access  and
  450. to access a debugger at the press of a key.  The fact that all  these
  451. features  are  combined in one program means that correcting
  452. errors and making changes is as fast as possible without the  need
  453. for slow disk accesses and other programs.
  454.      This chapter details the use of the editor and how to
  455. assemble program  - it does not detail the assembler or the
  456. debugger themselves, they are covered in the following chapters.
  457.      To  run GenAM, enter the command GENAM2 from the CLI. When it has
  458. loaded it will open an empty window, ready for you to enter and
  459. assemble your programs.
  460.  
  461. THE EDITOR
  462.      A  text  editor is a program which allows you  to  enter  and
  463. alter lines of text, store them on disk, and load them back again.
  464. There  are two types of text editors:  line editors,  which  treat
  465. each  line separately and can be very tricky to  use,  and  screen
  466. editors,  which display your text a screen at a time.  The  latter
  467. tend to be much easier to use.
  468.      The GENAM is a screen editor which allows you to enter and edit
  469. text and save and load from disk, as you would expect. It also lets
  470. you print all or some of your text, search and replace text patterns.
  471. It is intuition based, which means it uses all the user friendly
  472. features of amiga programs that you have become familiar
  473. with on your computer such as windows, menus and mice. However, if
  474. you're a die-hard,  used to the hostile world of computers  before
  475. the  advent of WIMP's,  you'll be pleased to know that you can  do
  476. practically everything you'll want to do from the keyboard without
  477. having to touch a mouse.
  478.      The editor is 'RAM-based',  which means that the file you are
  479. editing stays in memory for the whole time,  so you don't have  to
  480. wait while your disk grinds away loading different sections of the
  481. file  as you edit.  As the amiga can have so much memory, the  size
  482. limitations often found in older computer editors don't exist with
  483. GenAM;  if you have enough memory you can edit files of over  300k
  484. (though make sure your disk is large enough to cope with saving it
  485. if  you do !).
  486.         As all editing operations, including things like searching,
  487. are RAM based they act blindingly quickly. When you have typed in your
  488. program it is not much use if you are unable to save it to disk,  so
  489. the editor has a comprehensive range of save and load options,
  490. allowing you to save all or part of the text and to load other files
  491. into the middle of the current one, for example.
  492.      To  get  things to happen in the editor,  there  are  various
  493. methods available to you.  Features may be accessed in one or more
  494. of the following ways;
  495.  
  496.      Using a single key, such as a Function or cursor key:
  497.  
  498.      Clicking on a menu item, such as SAVE:
  499.  
  500.      Using  a  menu  shortcut,   by  pressing  the right amiga key
  501.      (subsequently  referred  to  as  (amiga))  in  conjunction   with
  502.      another such as (AMIGA)-F for Find:
  503.  
  504.      Using  the control key (subsequently referred to as Ctrl)  in
  505.      conjunction  with  another,  such as Ctrl-A for  cursor  word
  506.      left:
  507.  
  508.      Clicking on the screen, such as in the window itself.
  509.  
  510.      The  menu short cuts have been chosen to be easy and  obvious
  511. to  remember, the cursor key functions are based on those in the
  512. amigaBASIC editor check, while the Ctrl commands are based on those
  513. used  in Wordstar, and many other compatible editors since.
  514.      If  at  any time you get stuck,  pressing the HELP  key  will
  515. bring  up  a comprehensive display of the keys for  functions  not
  516. visible in menus.
  517.  
  518. A FEW WORDS ABOUT REQUESTERS
  519.         The editor makes extensive use of requesters,  so it  is
  520. worth recapping how to use them,  particularly for entering  text.
  521. The  editor's requesters contains string gadgets and buttons.
  522.         String gadgets enables to enter and edit text, and are
  523. depicted by a box containing the text, and with a block indicating the
  524. cursor position. Characters may be typed in and corrected using the
  525. (BACKSPACE), (DEL), and cursor keys. You can clear the whole edit
  526. field by pressing (AMIGA)-X. Ypu can move the cursor to the beginning
  527. by pressing (SHIFT) and left cursor key, or to the end by (SHIFT) and
  528. right cursor key. If there is more than one editable text field in a
  529. dialog box, you can move between them by clicking near them with the
  530. mouse.
  531.         Buttons  may  be  clicked on with the  mouse  and  cause  the
  532. requester to go away.  Usually there is a default button, shown
  533. by having a double border. Pressing (RETURN) on  the keyboard is
  534. equivalent to clicking on the default button, so long as a string
  535. gadget is active.
  536.         Some requesters allow only a limited range of  characters
  537. to  be  typed into them - for example the Goto Line requester.
  538.  
  539. THE FILE REQUESTER
  540.         The file requester is used to select file names for the disk
  541. input and output facilities of the editor. In it's simplest form all
  542. you need is to click on the file on the cancel button. At the top of
  543. Requester is the drawer specification, this determines which disk and
  544. sub-directory is displayed and can include wildcards, for example the
  545. specification:
  546.  
  547. df1:examples/#?.s
  548.  
  549. will display all files ending in .s. If you edit this specification,
  550. pressing the (RETURN) key will cause the directory to be read and
  551. displayed in the main part of the requester. Files may be selected by
  552. clicking on them and pressing (RETURN) or clicking on OK. The file
  553. list shows sub-directories with the (dir) prefix and the scroll bar
  554. may be used to navigate the file list. Files mey be selected or the
  555. requester cancelled while the directory is still being read! When
  556. initially invoked, only the first fiew files will be displayed. To
  557. update the file listm, click on the slider on the right of the
  558. filename list.
  559.         NOTE: Teh file requester uses the ARP libarary by Charlie
  560. Heath. If this library is not found then a simple string gadget will
  561. be used in it's place, in the same way as GenAm version 1. More
  562. details of the ARP library can be found in the ARP sub-directory on
  563. disk two.
  564.  
  565. ENTERING TEXT AND MOVING THE CURSOR
  566.      Having loaded GenAM, you will be presented with an empty
  567. window  with a status line at the top and an orange block, which is
  568. the cursor, in the top left-hand corner.
  569.      The  status  line  contains  information  about  the   cursor
  570. position in the form of Line Column offsets as well as the  number
  571. of  bytes of memory which are free to store your  text.  Initially
  572. this  is  displayed as 59980,  as the default text size  is  60000
  573. bytes.  You  may change this default if you  wish,  together  with
  574. various other options,  by selecting Preferences, described later.
  575. The  missing  20  bytes  are  used  by  the  editor  for  internal
  576. information.  The  rest of the status line area is used for  error
  577. messages, which will usually be accompanied with a 'display flash'
  578. to alert you. Any message that get  printed wil  be removed
  579. subsequently when you press a key.
  580.      To enter text,  you type on the keyboard.  As you press a key
  581. it  will  be shown on the screen and the cursor will  be  advanced
  582. along the line.  If you are a good typist you may be able to  type
  583. faster  than  the editor can re-display the  line;  if  so,  don't
  584. worry,  as the program will not lose the keystrokes and will catch
  585. up  when you pause.
  586.         At the end of each line you press the (RETURN) key (or the
  587. Enter key on the numeric pad) to start the next  line. You can correct
  588. your mistakes by pressing the Backspace key, which deletes the
  589. character to the left of the cursor, or the Delete key, which removes
  590. the character the cursor is over.
  591.      The  main  advantage  of a computer editor as  opposed  to  a
  592. normal typewriter,  is its ability to edit things you typed a long
  593. time  ago.  The  editor's large range of  options  allow  complete
  594. freedom to move around your text at will.
  595.  
  596. CURSOR KEYS
  597.      To move the cursor around the text to correct errors or enter
  598. new characters, you use the cursor keys, (the arrows). If you move
  599. the  cursor  past the right-hand end of the line  this  won't  add
  600. anything to your text,  but it you type some text at the point the
  601. editor  will  automatically add the text to the real  end  of  the
  602. line.  If  you type in long lines the window display  will  scroll
  603. sideways if necessary.
  604.      If  you cursor up at the top of the window the  display  will
  605. either  scroll  down if there is a previous  line,  or  print  the
  606. message  Top of file in the status line.  Similarly if you  cursor
  607. down  off the bottom of the window the display will either  scroll
  608. up if there is a following line, or print the message End of file.
  609.      For those of you used to Wordstar,  the keys Ctrl-S,  Ctrl-D,
  610. Ctrl-E and Ctrl-X work in the same way as the cursor keys.
  611.      To move immediately to the start of the current  line,  press
  612. Ctrl  (left arrow),  to move to the end of the current line  press
  613. Ctrl (right arrow).
  614.      To  move  the cursor a word to the left,  press  Shift  (left
  615. arrow) and to the right press Shift (right arrow). You cannot move
  616. a  cursor past the end of a line with this.  A word is defined  as
  617. anything surrounded by a space,  a tab or a start or end of  line.
  618. The keys Ctrl-A and Ctrl-F also move the cursor left and sight  on
  619. a word basis.
  620.      To move the cursor a page up, you can click on the upper grey
  621. part  of  the vertical scroll bar,  or press Ctrl-R or  Shift  (up
  622. arrow). To move the cursor a page down, you can click on the lower
  623. grey  part  of  the scroll bar,  or press Ctrl-C  or  Shift  (down
  624. arrow).
  625.      If you want to move the cursor to a specific position on  the
  626. screen you move the mouse pointer to the required place and  click
  627. (There is no Wordstar equivalent for this feature!)
  628.  
  629. TAB KEY
  630.         The Tab key inserts a special character (ASCII code 9) into
  631. your text, which on the screen looks like a number of spaces, but is
  632. rather  different.  Pressing Tab aligns the cursor onto  the  next
  633. 'multiple of 8' column,  so if you press it at the start of a line
  634. (column 1) the cursor moves to the next multiple of 8 +  1,  which
  635. is column 9.  Tabs are very useful indeed for making items line up
  636. vertically  and its main use in GenAM is for  making  instructions
  637. line up.  When you delete a tab the line closes up as if a  number
  638. of  spaces had been removed.  The advantage of tabs is  that  they
  639. only  take  up 1 byte of memory,  bat can show on screen  as  many
  640. more, allowing you to tabulate your program neatly. You can change
  641. the  tab size before or after loading GenAM using the  Preferences
  642. command described shortly.
  643.  
  644. BACKSPACE KEY
  645.      The  Backspace key removes the character to the left  of  the
  646. cursor.  If you backspace at the very beginning of a line it  will
  647. remove  the 'invisible' carriage return and join the line  to  the
  648. end of the previous line.  Backspacing when the cursor is past the
  649. end of the line will delete the last character on the line, unless
  650. the line is empty in which case it will re-position the cursor  on
  651. the left of the screen.
  652.  
  653. DEL KEY
  654.      The Delete key removes the character under the cursor and has
  655. no effect if the cursor is past the end of the current line.
  656.  
  657. GOTO A PARTICULAR LINE
  658.      To move the cursor to a particular line in the text, click on
  659. Goto line..  from the Options menu, or press (AMIGA)-G. A requester
  660. will appear allowing you to enter the required line number.  Press
  661. (RETURN) or click on OK button to go to the line or click on  Cancel
  662. to abort the operation.  After clicking on OK the cursor will move
  663. to the specific line,  re-displaying if necessary,  or give  error
  664. End of file if the line does't' exist.
  665.  
  666. GOTO TO TOP OF FILE
  667.         To  move to the top of the text, click on Goto Top from the
  668. Options  menu,  or  press (AMIGA)-T. The screen will be  re-drawn if
  669. requested.
  670.         NOTE: (AMIGA)-upcurser goes to the previous page not to the
  671. top of file - this has been changed from DEVPAC 1 because some users
  672. found this sequence too easy to hit by mistake.
  673.  
  674. GOTO END OF FILE
  675.      To  move  the cursor to the start of the very  last  line  of
  676. text, click on Goto Bottom, or press (AMIGA)-B
  677.         NOTE: (AMIGA)-downcursor goes to the next page not to the
  678. bottom of file - this has been changed from DEVPAC 1 because some
  679. users found this sequence too easy to hit by mistake.
  680.  
  681. QUITTING GENAM
  682.           To leave GenAM, and remove it from memory, click on Quit
  683. from the Project menu, or press (AMIGA)-Q. If changes have been made
  684. to the text which have not  been saved to disk,  an alert box will
  685. appear asking for confirmation. Clicking on Cancel will return you to
  686. the editor, while clicking on OK will discard the changes and return
  687. you to the CLI.
  688.  
  689. DELETING TEXT
  690.  
  691. DELETE LINE.
  692.      The  current  line can be deleted from the text  by  pressing
  693. Ctrl-Y.
  694.  
  695. DELETE TO END OF LINE.
  696.         The text from the cursor position to the end of the current
  697. line can be deleted by pressing Ctrl-Q. (This is equivalent to the
  698. Wordstar sequence Ctrl-Q Y).
  699.  
  700. UNDELETE LINE
  701.      When a line is deleted using either of the above commands  it
  702. is  preserved in an internal buffer,  and can be re-inserted  into
  703. the text by pressing Ctrl-U,  or the Undo key. This can be done as
  704. many times as required,  particularly useful for repeating similar
  705. lines or swapping over individual lines.
  706.  
  707. DELETE ALL TEXT
  708.      To clear out the current text, click on Clear from the Project
  709. menu, or press (AMIGA)-C. If you have made any changes to the text
  710. that have not been saved onto the disk, a confirmation is required
  711. and  the  requisite alert box will appear.  Clicking  on  OK  will
  712. delete the text, or Cancel will abort the operation.
  713.  
  714. DISK OPERATIONS
  715.         It is no use being able to type in text if you are unable to
  716. save it anywhere perminently, or load it back subsequently, so the
  717. editor has a comprehensive set of features to read from and write to
  718. disk.
  719.  
  720. SAVING TEXT
  721.      To save the text you are currently editing,  click on Save As
  722. from the Project Menu, or press (AMIGA)-S. The File requester
  723. will appear,  allowing you to select a suitable disk and filename.
  724. Clicking  OK or pressing Return will then save the file  onto  the
  725. disk.  If an error occurs a requester will appear showing a sutable
  726. error message, or an AmigaDOS error number, the exact meaning of which
  727. can be found in Appendix A.
  728.      If you click on Cancel the text will not be  saved.  Normally
  729. if  a  file  exists  with the same name it  will  be  deleted  and
  730. replaced  with the new version,  but if Backups are selected  from
  731. the  Preferences  options then any existing file will  be  renamed
  732. with  extension .BAK (deleting any existing .BAK file) before  the
  733. new version is saved.
  734.  
  735. SAVE
  736.         If you have already done a save as (or a load), GenAm will
  737. remember the name of the file and display it in the title bar of the
  738. window. If you want to save it without having to bother with the file
  739. requester. You can click on save on the Project menu, or press Shift-
  740. (AMIGA)-S, and it will use the old name and save it as above. If you
  741. try to sve without having previously specified a filename you will be
  742. presented with a file requester, as in save as.
  743.  
  744. LOADING TEXT
  745.      To  load a new file, click on Load from the Project menu, or
  746. press (AMIGA)-L. If you have made any changes that have not been
  747. saved, a confirmation will be required. The file requester will
  748. appear, allowing you to specify the disk and filename. Assuming you do
  749. not cancel, the editor will attempt to load the file. If  it will fit,
  750. the file is loaded into memory and the window is re-drawn. If it will
  751. not fit an alert box will appear warning you, and you should use
  752. preferances to make the edit buffer size larger, then try to load it
  753. again.
  754.  
  755. INSERTING TEXT
  756.      If  you  want to read a file from disk and insert it  at  the
  757. current  position in your text click on Insert File from the  File
  758. menu or press (AMIGA)-I. The file requester will appear and assuming
  759. that you do not cancel, the file will be read from the disk and
  760. inserted, memory permitting.
  761.  
  762. CHANGE DIRECTORY
  763.       This command lets you change the current directory that you are
  764. using. Simply uses the file requester to change the directory you
  765. wish.
  766.  
  767. SEARCHING AND REPLACING TEXT
  768.      To  find a particular section of text click on Find from  the
  769. Search menu,  or press (AMIGA)-F. A dialogue box will appear, allowing
  770. you to enter the Find and Replace strings. If you click on Cancel,
  771. no action will be taken;  if you click Next (or press Return)  the
  772. search will start forwards,  while clicking on Previous will start
  773. the  search backwards.
  774.         If you do not wish to replace, leave the Replace string empty.
  775. If the search was successful, the screen will be re-drawn at that
  776. point with the cursor positioned at the start of the string. If the
  777. search string could not be found, the message Not Found will appear in
  778. the status area and the cursor will remain unmoved. By default the
  779. search is always case-independant, so for example if you enter the
  780. search string as test you could find the words TEST,  Test or test.
  781. If you click on the Upper & Lower case Different button the search
  782. will be case dependant.
  783.      To find the next occurrence of the string click on Find  Next
  784. from  the Search menu,  or press (AMIGA)-N.  The search starts at the
  785. position just before the cursor.
  786.      To search for the previous occurrence of the string click  on
  787. Find Previous from the Search menu, or press (AMIGA)-P.
  788.      Having  found an occurrence of the required text,  it can  be
  789. replaced  with the Replace string by clicking on Replace from  the
  790. Search menu,  or pressing (AMIGA)-R.  Having replaced it,  the  editor
  791. will then search for the next occurrence.
  792.      If  you wish to replace every occurrence of the  find  string
  793. with the replace string from the cursor position onwards, click on
  794. Replace  All from the Search menu.  During the global replace  the
  795. ESC  key  can be used to abort and the status area will  show  how
  796. many  replacements were made.  There is deliberately  no  keyboard
  797. equivalent for this to prevent it being chosen accidentally.
  798.         To search and replace tab characters just press (TAB) when
  799. typing in the dialog box. Other control characters may be searched for
  800. by typing them in directly ((CTRL)-G for example). However do not use
  801. this for CR((CTRL)-M) and LF((CTRL)-J) characters.
  802.  
  803. BLOCK COMMANDS
  804.      A  Block is a marked section of text which may be  copied  to
  805. another section, deleted, printed or saved onto disk. The function
  806. keys are used to control blocks.
  807.      Block markers remain during all editing commands, moving where
  808. necessary. and are only reset by the commands New, Delete Block, and
  809. Load.
  810.  
  811. MARKING A BLOCK
  812.      The  start of a block is marked by moving the cursor  to  the
  813. required place and pressing key F1.  The end of a block is  marked
  814. by moving the cursor and pressing key F2. The start and end of the
  815. block do not have to be marked in a specific order - if it is more
  816. convenient you may mark the end of the block first.
  817.      A marked block is highlighted by showing the text in reverse.
  818. While  you  are  editing  a  line that  is  within  a  block  this
  819. highlighting  will not be shown but will be re-displayed when  you
  820. leave that line or choose a command.
  821.  
  822. SAVING A BLOCK
  823.      Once a block has been marked, it can be saved by pressing key
  824. F3.  If no block is marked,  the message What blocks! will appear.
  825. If  the start of the block is textually after its end the  message
  826. Invalid  block!  will  appear.  Both  errors  abort  the  command.
  827. Assuming  a  valid block has been marked,  the file requester
  828. will appear,  allowing you to select a suitable disk  and
  829. filename.  If  you save the block with a name that already  exists
  830. the  old  version will be overwritten - no backups are  made  with
  831. this command.
  832.  
  833. COPYING A BLOCK
  834.      A marked block may be copied,  memory permitting,  to another
  835. part of the text by moving the cursor to where you want the  block
  836. copied and pressing key F4. If you try to copy a block into a part
  837. of itself, the message Invalid block will appear and the copy will
  838. be aborted.
  839.  
  840. DELETING A BLOCK
  841.      A  marked  block  may be deleted from the  text  by  pressing
  842. Shift-F5.  The  shift key is deliberately required to  prevent  it
  843. being  used accidentally.  A deleted block is  remembered,  memory
  844. permitting, in the block buffer, for later use.
  845.         There are two key sequences with this command for
  846. compatibility with both DEVPAC version 2 and DEVPAC version 1.
  847.  
  848. COPY BLOCK TO BLOCK BUFFER
  849.      The  current marked block may be copied to the block  buffer,
  850. memory permitting,  by pressing Shift-F4.  This can be very useful
  851. for  moving blocks of text between different files by loading  the
  852. first,  marking  the block,  copying it to the block  buffer  then
  853. loading the other file and pasting the block buffer into it.
  854.  
  855. PASTING A BLOCK
  856.      A  block  in the block buffer may be pasted  at  the  current
  857. cursor position by pressing F5.
  858.     The  block  buffer will be lost if the edit  buffer  size  is
  859. changed or an assembly occurs.
  860.  
  861. PRINTING A BLOCK
  862.      A  marked  block may be sent to the printer  by  printing  on
  863. Print Block from the File menu, or by pressing (AMIGA)-W. A requester
  864. will appear asking for the name of the printer, which defaults to
  865. PRT:, and clickingon ok will print the block. Of course the name can
  866. be any valid AmigaDOS device, so you could "print" the block to disk
  867. if required. It is differant to Save Block in that tabs are expanded
  868. to spaces.
  869.      If you try to print when there is no block marked,  the whole
  870. file will be printed.
  871.  
  872. MISCELLANEOUS COMMANDS
  873.  
  874. HELP SCREEN
  875.         The key equivalents for the commands not found in menus can
  876. be seen by pressing the HELP key, or (AMIGA)-H. A dialogue box will
  877. appear showing the function key uses, the version of GenAm that is
  878. running and the total free memory in the system.
  879.  
  880. PREFERENCES
  881.      Selecting Preferences..  from the Options menu will produce a
  882. dialogue box allowing you to change several editor settings.
  883.  
  884. TABS
  885.      By default,  the tab setting is 8, but this may be changed to
  886. any value from 2 to 16.
  887.  
  888. TEXT BUFFER SIZE
  889.      By default the text buffer size is 60000 bytes,  but this can
  890. be changed from 4000 to 999000 bytes.  This determines the largest
  891. file size that can be loaded and edited,  Care should be taken  to
  892. leave  sufficient room in memory for assembly or running  MonAm.
  893. Changing  the editor work-space size will cause any text  you  are
  894. currently editing to be lost,  so a confirmation is required if it
  895. has not been saved.
  896.  
  897. BACKUPS
  898.      By  default the editor doesn't make backups of programs  when
  899. you  save them,  but this can be turned on by clicking on the  Yes
  900. radio button.
  901.  
  902. AUTO INDENTING
  903.      It can be particularly useful when editing programs to indent
  904. subsequent  lines from the left,  so the editor supports an  auto-
  905. indent mode.  When active, an indent is added to the start of each
  906. new line created when you press RETURN. The contents of the indent
  907. of  the new line is taken from the white space (i.e.  tabs  and/or
  908. spaces) at the start of the previous line.
  909.  
  910. END OF LINE
  911.      By default (i.e. when Stop is selected) when you press cursor
  912. left at the beginning of a line or cursor right at the end of line the
  913. cursor does not move. Changing this item to wrap causes the cursor to
  914. move to the previous line if you press cursor left at the beginning
  915. and to the next line if you press curser left at the beginning and the
  916. next line if you presscursor right at the end. The best way to find
  917. out which you prefer is to try using both settings.
  918.  
  919. LOAD MONAM
  920.      By  default  a  copy of MonAM is  loaded  during  the  editor
  921. initialisation,  allowing it to be accessed at the press of a key.
  922. Should  this not be required it can be disabled with this  option.
  923. This will save around 24k of memory.  The new value of this option
  924. will  only  have  an effect if you save the  preferences  and  re-
  925. execute the editor.
  926.  
  927. AUTOSIZE WINDOW
  928.      By default, Genam will not use the entire screen display, but if
  929. this is selected then it will make it's initial window as large as
  930. possible.
  931.  
  932. SAVING PREFERENCES
  933.      If  you click on the Cancel button any changes you make  will
  934. be ignored.  If you click on the OK button the  changes  specific
  935. will remain in force until you quit the editor.  If you would like
  936. the  configuration made permanent then click on the  Save  button,
  937. which will create the file GENST2.INF on your disk.  Next time you
  938. run GenST the configuration will be read from that file in the current
  939. directory. In  addition to saving the editor configuration  the
  940. current setting from the Assembly Options dialogue box are also saved.
  941. If the .INF file is not found in the current directory when the editor
  942. is loaded, the c: directory is also searched. This allows a global
  943. settings as well as specific local ones.
  944.  
  945. ASSEMBLING & RUNNING PROGRAMS
  946.      All assembly and run options can be found on the Program menu
  947.  
  948. ASSEMBLY
  949.      To  assemble the program you are currently editing  click  on
  950. Assemble from the Program menu, or press (AMIGA)-A. The meaning of the
  951. various  options,  together  with the assembly process  itself  is
  952. detailed in the next chapter.  The only option covered here is the
  953. Output option.
  954.      GenAM  can  assemble  to  disk,   to  memory,  or  nowhere  -
  955. assembling to nowhere is ideal for syntax checking while  assembly
  956. to  memory is much faster than to disk and good for trying  things
  957. out quickly.
  958.      If you assemble to disk and you haven't saved your program source
  959. code yet the file will be based on the name NONAME.
  960.      After  you  click on Assembly or press  RETURN  the  assembly
  961. process will start,  describe more fully in the next  chapter.  At
  962. the  end  of the assembly the program will wait for a  key  press,
  963. allowing you to read any messages produced,  before returning  you
  964. to the editor.  If there were any errors the editor will go to the
  965. first  erroneous line and display the error message in the  status
  966. bar.  Subsequent  errors  (and warnings) may  be  investigated  by
  967. pressing (AMIGA)-J.
  968.  
  969. RUNNING PROGRAMS
  970.      If you click on Run or press (AMIGA)-X (eXecute) you can then run
  971. a  program  previously assembled into memory.  When  your  program
  972. finishes it will return you to the editor.  If the assembly didn't
  973. complete  normally for any reason then it is not possible  to  run
  974. the program.
  975.      If  your  program crashes badly you may never return  to  the
  976. editor, so if in doubt save your source code before using this, or
  977. the following command.
  978.      If  only non-fatal errors occurred  during  assembly  (e.g.
  979. undefined  symbols)  you  will  still be  permitted  to  run  your
  980. program, at your own risk.
  981.  
  982. DEBUG
  983.      If you wish to debug a program previously assembled to memory
  984. click  on Debug form the Program menu, or press (AMIGA)-D. This will
  985. invoke  MonAM to  debug your  program,  including  any  debugging
  986. information specified.  Pressing Ctrl-C from MonAM will  terminate
  987. the debugger.
  988.      If  the  Load  MonAM option is disabled this  option  is  not
  989. available and the menu is disabled.
  990.  
  991. MONAM
  992.      Clicking on MonAM from the Program menu, or pressing (AMIGA)-M,
  993. will invoke MonAM in a similar way to if it was invoked by typing it's
  994. name in CLI, but instantly, as it  is  already  in  memory.  You will
  995. return  to  the  editor  on termination of the debugger.
  996.      If  the  Load  MonAM option is disabled this  option  is  not
  997. available and the menu is disabled.
  998.  
  999. JUMP TO ERROR
  1000.      During  an  assembly any warnings or errors  that  occur  are
  1001. remembered,  and can be recalled from the editor. Clicking on Jump
  1002. to  Error from the Program menu,  or pressing (AMIGA)-J will move  the
  1003. cursor  to the next line in your program which has an  error,  and
  1004. display  the  message in the status line of the  window.  You  can
  1005. step to the next one by pressing (AMIGA)-J again,  and so on,  letting
  1006. you  correct errors quickly and easily.  If there are  no  further
  1007. errors when you select this option the message No more errors will
  1008. appear,  or if there are no errors at all the message What errors!
  1009. will appear.
  1010.  
  1011. THE EDITOR WINDOW
  1012.         The window used by the editor works like the most other Amiga
  1013. windows, so you can move it around by using the drag gadget on the top
  1014. of it, you can change it's size by dragging on the size gadget and
  1015. control it's position relative to the other windows by using the front
  1016. and back gadgets. Clicking on the close gadget is equivelant to
  1017. choosing Quit fron the project menu. Like all intuition windows, it
  1018. has to be active for you to be able get at it's menu items. If you
  1019. have a larger than normal screen size (eg. a european PAL system which
  1020. has 256 vertical lines) you can re-size the window to be the full size
  1021. of your screen.
  1022.         When GenAm is busy doing a disk access or assembly the cursor
  1023. changes to an hourglass and all menu items are made grey.
  1024.         NOTE: When using GenAm (And MonAm) on PAL machines with
  1025. external RAM, you may sometimes get two mouse pointers; one will be
  1026. the normal intuition pointer, the other will be the custom pointer
  1027. allocated with the program you are using. Do not be alarmed - this
  1028. seems to be a harmless bug in intuition.
  1029.  
  1030. SYSTEM REQUESTERS
  1031.         When a system requester appears from the editor (eg. File not
  1032. found), pressing any key is equivelant to clicking on cancel.
  1033.  
  1034. CHAPTER 3: MACRO ASSEMBLER
  1035.  
  1036. INTRODUCTION
  1037.      GenAM is a powerful,  fast,  full  specification  assembler,
  1038. available  instantly  from within the editor or as a  stand  alone
  1039. program.  It  converts the text typed or loaded into  the  editor,
  1040. optionally  together  with the files read from the  disk,  into  a
  1041. binary file suitable for immediate execution or linking, or into a
  1042. memory image for immediate execution from the editor.
  1043.  
  1044. INVOKING THE ASSEMBLER
  1045.  
  1046. FROM THE EDITOR
  1047.      The  assembler  is  invoked from the editor  by  clicking  on
  1048. Assemble from the Program menu,  or by pressing (AMIGA)-A.  A dialogue
  1049. box will appear which looks like this (almost);
  1050.  
  1051. |------------------------------------------------|
  1052. | Program type   Executable    Linkable          |
  1053. | Symbols case   Dependant     Independant       |
  1054. | Debug info     None    Normal   Exports        |
  1055. | List           None  Screen  Printer  Disk     |
  1056. | Assembly       Fast          Slower            |
  1057. | Output to      None          Memory            |
  1058. |       ______________________________________   |
  1059. | Disk |______________________________________|  |
  1060. |                Assembly options                |
  1061. | Cancel                        Assemble         |
  1062. | _______________________________________________|
  1063.  
  1064.      PROGRAM  TYPE This lets you select between executable or
  1065. linkable format  output.  The differences between these  are  detailed
  1066. later.
  1067.  
  1068.      SYMBOLS  CASE  This lets you select whether labels  are  case
  1069. dependant or not. If case Dependant is selected then Test and test
  1070. would  be different labels,  if the case Independant  is  selected
  1071. then they would be the same.
  1072.  
  1073.      DEBUG  INFO  If  you wish to debug your  program  using  your
  1074. original  symbols you can select Normal or Extended  debug  modes.
  1075.  
  1076.      LIST  selecting Printer will divert the assembly listing to the
  1077. PRT: device, or selecting Disk will send the listing to a
  1078. file based on the source filename, but with the extension .LST.
  1079.  
  1080.      ASSEMBLER  Normally this option should be left as fast selected,
  1081. but if the assembler runs out of memory select slower. Selecting
  1082. Slower forces the assembler to use little memory as possible thus
  1083. slowing down things like reading include files.
  1084.  
  1085.      OUTPUT TO This lets you select where the output file is to be
  1086. created. None means it is 'thrown away', ideal for syntax checking
  1087. a program;  Memory means it is assemble into a buffer allowing  it
  1088. to be run or debugged instantly form the editor without having  to
  1089. create  a  disk  file:  Disk means a file  will  be  created.  The
  1090. selection  of the name of this file can be left to the  assembler,
  1091. using rules described shortly.
  1092.      The  first  two options may be specified in the  source  file
  1093. using the OPT directive.
  1094.      Having selected your required options you should click on the
  1095. Assemble  button (or press Return) to start the assembly.  At  the
  1096. end of assembly you should press any key to return to the  editor.
  1097. If any errors occurred the cursor will be positioned on the  first
  1098. offending line.
  1099.  
  1100. STAND ALONE ASSEMBLER
  1101.  
  1102. COMMAND LINE FORMAT
  1103.      The assembler, Genim2, may by invoked directly from the CLI.
  1104. The command line should be the form:
  1105.  
  1106. GenIm2   mainfile    <-options>  [-options]
  1107.  
  1108.      The  mainfile  should  be  the name  of  the  file  requiring
  1109. assembly and if no extension is specified defaults to ,S.  Options
  1110. should  follow  this  donated by a -  sign  then  an  alphabetical
  1111. character.   Allowed   options  are  shown  below  together   with
  1112. equivalent OPT directives :
  1113.  
  1114.      B    no binary file should be created
  1115.  
  1116.      C    case insensitive labels (OPT C-)
  1117.  
  1118.      D    debug (OPT D+)
  1119.  
  1120.      I    specify include directory (follow immediatly with path)
  1121.  
  1122.      L    linkable code (OPT L+)
  1123.  
  1124.      M    use slow(low memory) assembly mode. See above. Not the
  1125.           same as OPT m+
  1126.  
  1127.      O    specify output filename (follows immediately after O)
  1128.  
  1129.      P    specify  listing  filename  (should  follow  immediately
  1130.           after P) defaults to source filename with extension .LST
  1131.  
  1132.      Q    pause for key press after assembly
  1133.  
  1134.      T    specifies the tab setting for listing. For example -T10
  1135.           uses a tab setting of 10.
  1136.  
  1137.      X    used when generating linkable code to export only the
  1138.           exported (XDEFed) symbols (OPT X+)
  1139.  
  1140.      NOTE: The options used by GenIm2 are rather differant to those
  1141. used in DEVPAC version 1 but the same as DEVPAC version 2.
  1142.  
  1143.         The default is to create an executable binary file with  the
  1144. name based on the source file and output file type,  no  listing,
  1145. with no case sensitive labels. For example,
  1146.  
  1147. genim2    test  -b
  1148.  
  1149. assembles test.s with no binary output file
  1150.  
  1151. genim2    test  -oram:test -p -iminc/
  1152.  
  1153. assembles test.s into a binary file ram:test.prg and a listing  file
  1154. to test.lst, with an include directory of myinc.
  1155.  
  1156. genim2    test  -ldppprt:
  1157.  
  1158. assembles  test.s into linkable code with debug and a  listing
  1159. to  the printer as set using the Amiga Preferances tool.
  1160.  
  1161. OUTPUT FILENAME
  1162.      GenAM  has  certain rules regarding the  calculation  of  the
  1163. output filename, using a combination of that specified at assembly
  1164. time  (either in the Disk: string gadget in the requester) or
  1165. using the -O option on the command line) and the Output directive:
  1166.      If an output filename is explicitly given at assembly time then:
  1167.      name = explicit filename
  1168.  
  1169. else:
  1170.      if the Output directive has not been used then
  1171.           name = source filename without an extension or .O
  1172.      else if the Output directive specifies an extension then
  1173.           name = source filename + extension in Output
  1174.      else
  1175.           name = name in Output
  1176.  
  1177. ASSEMBLY PROCESS
  1178.      GenAM is a two-pass assembler; during the first pass it scans
  1179. all  the text in memory and from disk if required,  building up  a
  1180. symbol  table.  If  syntax  errors are found  on  the  first  pass
  1181. assembly these will be reported and assembly will stop at the  end
  1182. of  the  first  pass,   otherwise,  during  the  second  pass  the
  1183. instructions are converted into bytes,  a listing may be  produced
  1184. if required and a binary file can be created on the  disk.  During
  1185. the  second  pass any further errors and warnings will  be  shown,
  1186. together with a full listing and symbol table if required.
  1187.      During assembly, any screen output can be paused by holding down
  1188. the right mouse button or, when using the stand alone assembler, by
  1189. pressing  any key (pressing (RETURN) will  resume it).  Assembly  may
  1190. be  aborted  by pressing Ctrl-C, although doing so will make any
  1191. binary file being created  invalid  as  it  will be incomplete  and
  1192. should  not  be executed.
  1193.  
  1194. ASSEMBLY TO MEMORY
  1195.         To reduce development time GenAM can assemble  programs  to
  1196. memory, allowing immediate execution or debugging from the editor.
  1197.         A  program running from memory is just like any other  normal
  1198. AmigaDOS  program and should terminate using an RTS instruction with
  1199. the stack as the program was entered.
  1200.        Programs should be careful if they self-modify as a re-executed
  1201. program will be in its original state. The state is left as when the
  1202. program was previously executed.
  1203.        The current assembly options can be made the default on re-
  1204. loading the editor if Save Preferences is used.
  1205.  
  1206. BINARY FILE TYPES
  1207.      There are two types of binary files which may be produced  by
  1208. GenAM, for different types of applications. They are distinguished
  1209. by the extension on the filename:
  1210.      If there is no extension then this is a directly executable file,
  1211. or if the extension is .o or .obj then this is an AmigaDOS linkable
  1212. file.
  1213.      Actually there are two sorts of executable files; those that are
  1214. designed to be run from the CLI and those that are designed to be run
  1215. from workbench. The differance is in the code that is part of the
  1216. program; the assembler cannot tell the differance. This is described
  1217. later.
  1218.      .o files cannot be run immediatly, but have to be read into a
  1219. linker, usually with other sections, and are known as linkable object
  1220. modules.
  1221.  
  1222. TYPES OF CODE
  1223.     Unlike  most 8-bit operating systems,  but like  most  16-bit
  1224. systems,  an executable program under AmigaDOS will not be loaded at
  1225. a  particular  address  but,  instead,  be loaded  at  an  address
  1226. depending on the exact free memory configuration at that time.
  1227.      To get around the problem of absolute addressing the ST  file
  1228. format includes relocation information allowing GEMDOS to relocate
  1229. the  program  after it has loaded it but before  running  it.  For
  1230. example the following program segment:
  1231.  
  1232.                move.l #string, a0
  1233.                .
  1234.                .
  1235.                .
  1236.      string    dc.b   'Press any key',0
  1237.  
  1238. places the absolute address of string into a register, even though
  1239. at  assembly  time the real address of string cannot  possibly  be
  1240. known.  Generally  the programmer may treat addresses as  absolute
  1241. even though the real addresses will not be known to him, while the
  1242. assembler  (or  linker) will look after the  necessary  relocation
  1243. information.
  1244.     NOTE: For certain programs, normally games or cross machine
  1245. development an absolute address may be required,  for this  reason
  1246. the ORG directive is supported.
  1247.  
  1248. The syntax of the assembler will now be described.
  1249.  
  1250. ASSEMBLER STATEMENT FORMAT
  1251.      Each  line  that is to be processed by the  assembler  should
  1252. have the following format;
  1253.  
  1254.      Label     Mnemonic       Operand(s)          Comment
  1255.      Start     move.l         d0,(a0)+            store the result
  1256.  
  1257.      Exceptions  to  this  are  comment  lines,  which  are  lines
  1258. starting with an asterisk or semi-colon,  and blank  lines,  which
  1259. are  ignored.  Each field has to be separated from the  others  by
  1260. white space - any number or mixture of space and tab characters.
  1261.  
  1262. LABEL FIELD
  1263.      The label should normally start at line 1,  but if a label is
  1264. required  to start at another position then it should be  followed
  1265. immediately   by  a  colon  (:).   Labels  are  allowed   on   all
  1266. instructions, but are prohibited on some assembler directives, and
  1267. absolutely  required  on  others.  A  label  may  start  with  the
  1268. characters A-Z,  a-z,  or underline (_),  and may continue with  a
  1269. similar  set together with the addition of the digits 0-9 and  the
  1270. period (.).
  1271.      Labels  starting with a period are  local  labels,  described
  1272. later. Sequances of digits terminated by a $ are also labels. Macro
  1273. names and register equate symbols may not have periods in them,
  1274. though macro names may start with a period. By default the first 127
  1275. characters of labels are significant, though this can be reduced if
  1276. required.  Labels should not be the same as register names, or the
  1277. reserved words SR, CCR or USP.
  1278.      By default labels are case-sensitive though this may be changed.
  1279.  
  1280.      Some example legal labels are ;
  1281.  
  1282. test, Test, TEST, _test, _test.end, test5, _5test
  1283.  
  1284.      Some illegal labels are;
  1285.  
  1286.      5test, _&e, test>,
  1287.  
  1288.      There  are  certain reserved symbols  in  GenST,  denoted  by
  1289. starting with two underline characters.  These are __LK,  __RS and
  1290. __G2.
  1291.  
  1292. MNEMONIC FIELDS
  1293.      The  mnemonic  field  comes after the  label  field  and  can
  1294. consist  of 68000 assembler instructions,  assembly directives  or
  1295. macro  calls.  Some  instructions  and  directives  allow  a  size
  1296. specifier,  separated from the mnemonic by a period. Allowed sizes
  1297. are .B for byte,  .W for word, .L for long and .S for short. Which
  1298. size specifiers are allowed in each case depends on the particular
  1299. instruction or directive.  GenAM is case-sensitive to mnemonic and
  1300. directive names, so Move is the same as move and the same as mOvE,
  1301. for example.
  1302.  
  1303. OPERAND FIELD
  1304.      For those instructions or directives which require  operands,
  1305. this field contains one or more parameters,  separated by  commas.
  1306. GenST is case-sensitive regarding register names so they may be in
  1307. either or mixed case.
  1308.  
  1309. COMMENT FIELD
  1310.      Any  white space not within quotes found after  the  expected
  1311. operand(s)  is  treated  as a delimiter before the  start  of  the
  1312. comment, which will be ignored by the assembler.
  1313.  
  1314. EXAMPLES OF VALID LINES
  1315.  
  1316.                move.l  d0,(a0)+         comment is here
  1317.  
  1318.      loop      TST.W       d0
  1319.  
  1320.      lonely.label
  1321.  
  1322.         rts
  1323.  
  1324. * this is a complete line of comment
  1325.  
  1326. ; and so is this
  1327.  
  1328.      indented: link A6,#-10 make room
  1329.  
  1330. a_string: dc.b 'spaces allowed in quotes' a string
  1331.  
  1332. EXPRESSIONS
  1333.      GenAm allows complex expressions and supports full  operator
  1334. precedence, parenthesis and logical operators.
  1335.      Expressions are in two types -absolute and relative - and the
  1336. distinction is important. Absolute expressions are constant values
  1337. which are known at assembly time. Relative expressions are program
  1338. addresses  which  are  not known at assembly-time  as the AmigaDOS
  1339. loader  can  put  the  program where  it  likes  in  memory.  Some
  1340. instructions and directives place restrictions on which types  are
  1341. allowed  and  some  operators cannot be used  with  certain  type-
  1342. combinations.
  1343.  
  1344. OPERATORS
  1345.      The operators available, in decreasing order of precedence, are:
  1346.      monadic minus (-) and plus (+)
  1347.      bitwise not (~)
  1348.      shift left (<<) and shift right (>>)
  1349.      bitwise And (&), Or (!), and Xor (^)
  1350.      multiply (*) and divide (/)
  1351.      addition (+) and subtraction (-)
  1352.      equality (=), less than (<), greater than (>)
  1353.  
  1354.      The comparison operators are signed and return 0 if false  or
  1355. -1  ($FFFFFFFF) if true.  The shift operators take the  left  hand
  1356. operand and shift it the number of bits in the right hand  operand
  1357. and vacated bits are filled with zeros.
  1358.  
  1359.      This precedence can be overridden by the parentheses ( and ).
  1360. With operators of equal precedence, expressions are evaluated from
  1361. left-to-right.  Spaces  in  expressions (other than  those  within
  1362. quotes  as ASCII constants) are not allowed as they are  taken  as
  1363. the separator to the comment.
  1364.  
  1365.      All expression evaluation is done using 32-bit signed-integer
  1366. arithmetic, with no checking of overflow.
  1367.  
  1368. NUMBERS
  1369.      Absolute numbers may be in various forms;
  1370.  
  1371.           decimal constants, e.g. 1029
  1372.           hexadecimal constants, e.g. $12f
  1373.           octal constants, e.g. @730
  1374.           binary constants, e.g. %1100010
  1375.           character constants, e.g. 'X'
  1376.  
  1377.      $ is used to denote hex numbers,  % for binary,  @ for  octal
  1378. and single ' or double quotes " for character constants.
  1379.  
  1380. CHARACTER CONSTANTS
  1381.      Whichever  quote is used to mark the start of a  string  must
  1382. also  be used to denote its end and quotes themselves may be  used
  1383. in  strings delimited with the same quote character by  having  it
  1384. occur  twice.  Character  constants can be upto  4  characters  in
  1385. length and evaluate to right-justified longs with null-padding  if
  1386. required.  For example, her are some character constants and their
  1387. ASCII and hex values:
  1388.  
  1389.      "Q"       Q              $00000051
  1390.      "hi"      hi             $00006869
  1391.      "Test"    test           $54657374
  1392.      "it's"    it's           $6974277C
  1393.      'it''s'   it's           $6974277C
  1394.  
  1395.      Strings  used  in DC.B statements follow  slightly  different
  1396. justification rules, detailed with the directive later.
  1397.  
  1398.      Symbols  used  in  expressions will  be  either  relative  or
  1399. absolute,  depending on how they were defined.  Labels within  the
  1400. source  will  be  relative,  while those  defined  using  the  EQU
  1401. directive  will be the same type as the expression to  which  they
  1402. are equated.
  1403.      The  use of an asterisk (*) denotes the value of the  program
  1404. counter at the start of the instruction or directive and is always
  1405. a relative quantity.
  1406.  
  1407. ALLOWED TYPE COMBINATIONS
  1408.      The  table below summarises for each operator the results  of
  1409. the various type combinations of parameter an d which combinations
  1410. are  not allowed.  An R denotes a Relative result,  an  A  denotes
  1411. absolute  and a * denotes that the combination is not allowed  and
  1412. will produce an error message if attempted.
  1413.  
  1414.                     A op A   A op R   R op A   R op R
  1415. Shift operators       A        *        *         *
  1416. Bitwise operators     A        *        *         *
  1417. Multiply              A        *        *         *
  1418. Divide                A        *        *         *
  1419. Add                   A        R        R         *
  1420. Subtract              A        *        R         A
  1421. Comparisons           A        *        *         A
  1422.  
  1423. ADDRESSING MODES
  1424.      The available addressing modes are shown in the table  below.
  1425. Please   note  that  GenST  is  case-insensitive   when   scanning
  1426. addressing modes, so D0 and a3 are both valid registers.
  1427.  
  1428. FORM      MEANING                                 EXAMPLE
  1429. Dn        data register direct                    D3
  1430. An        address register direct                 A5
  1431. (An)      address register indirect               (A1)
  1432. (An)+     address reg indirect + post-increment.  (A5)+
  1433. -(An)     address reg indirect + pre-increment.   -(A0)
  1434. d(An)     address reg indirect with displacement  20(A7)
  1435. d(An,Rn.s)address register indirect with index    4(A6,D4.L)
  1436. d.W       absolute short address                  $0410.W
  1437. d.L       absolute long address                   $12000.L
  1438. d(PC)     program counter relative with offset    NEXT(PC)
  1439. d(PC,Rn.s)program counter relative with index     NEXT(PC,A2.W)
  1440. #d        immediate data                          #26
  1441.  
  1442. n         denotes register number from 0 to 7
  1443. d         denotes a number
  1444. R         denotes index register, either A or D
  1445. s         denotes size, either W or L, when omitted defaults to W
  1446.  
  1447. When  using address register indirect with index the  displacement
  1448. may be omitted, for example
  1449.  
  1450. move.l    (a3,d2.l),d0
  1451.  
  1452. will assemble to the same as
  1453.  
  1454. move.l    0(a3,d2.l),d0
  1455.  
  1456. SPECIAL ADDRESSING MODES
  1457.  
  1458. CCR       condition code register
  1459. SR        status register
  1460. USP       user stack pointer
  1461.  
  1462. In  addition to the above,  SP can be used in place of A7  in  any
  1463. addressing mode, e.g. 4(SP,D3.W)
  1464.      The data and address registers can also be denoted by use  of
  1465. the reserved symbols R0 through R15. R0 to R7 are equivalent to D0
  1466. to D7,  R8 to R15 are equivalent to A0 to A7. This is included for
  1467. compatibility with other assemblers.
  1468.  
  1469. LOCAL LABELS
  1470.      GenAm supports local labels,  that is labels which are  local
  1471. to  a  particular area of the source code.  These are  denoted  by
  1472. starting  with  a period and are attached to  the  last  non-local
  1473. label, for example;
  1474.  
  1475. lenl      move.l    4(sp),a0
  1476. .loop     tst.b     (a0)+
  1477.           bne.s     .loop
  1478.           rts
  1479. len2      move.l    4(sp),a0
  1480. .loop     tst.b     -(a0)
  1481.           bne.s     .loop
  1482.           rts
  1483.  
  1484.     There  are  two labels called .loop in this code segment but the
  1485. first is attached to lenl, the second to len2.
  1486.     If you wish to use global labels starting with a dot you may use
  1487. OPT U+ to allow this and make the underline character introduce local
  1488. labels.
  1489.     The local labels .W and .L are not allowed to avoid confusion with
  1490. the absolute addressing syntax.
  1491.  
  1492. AMIGA MACRO ASSEMBLER LOCAL LABELS
  1493.     You may also use strings of decimal digits terminated by the $
  1494. sign as local labels. This facility has been provided for
  1495. compatability with other assemblers; we reccomend the use of form
  1496. shown above as this makes programs much more readable.
  1497.  
  1498. SYMBOLS AND PERIODS
  1499.      Symbols which include the period character can cause problems
  1500. with GenAm due to absolute short addressing.
  1501.      The Motorola standard way of denoting absolute short addresses
  1502. causes  problems as periods are considered to be part of a  label,
  1503. best illustrated by an example:
  1504.  
  1505.           move.l    vector.w,d0
  1506.  
  1507. where vector is an absolute value, such as a system variable. This
  1508. would  generate an undefined label error,  as the label  would  be
  1509. scanned as vector.w.  To get around this,  the expression, in this
  1510. case a symbol, may be enclosed in brackets, e.g.
  1511.  
  1512.           move.l    (vector).w,d0
  1513.  
  1514. though the period mat still be used after numeric expressions, e.g.
  1515.  
  1516.           move.l    $4.w,d0
  1517.  
  1518.     NOTE: GenAm version 1 also supported the use of \  instead  of  a
  1519. period to denote short word addressing and this is still supported
  1520. in this version,  but this is not recommended due to the potential
  1521. for \W and \L to be mistaken for macro parameters.
  1522.  
  1523. INSTRUCTION SET
  1524.  
  1525. WORD ALIGNMENT
  1526.      All  instructions  with the exception of DC.B  and  DS.B  are
  1527. always  assembled on a word boundary.  Should you require  a  DC.B
  1528. explicitly on a word boundary,  the EVEN directive should be  used
  1529. before  it.  Although all instructions that require it  are  word-
  1530. aligned,  labels with nothing following them are not word  aligned
  1531. and can have odd values. This is best illustrated by an example;
  1532.  
  1533.           nop                 this is always word aligned
  1534.           dc.b      'odd'
  1535. start
  1536.           tst.l     (a0)+
  1537.           bne.s     start
  1538.  
  1539. The  above  code would not produce the required  result  as  start
  1540. would have an odd value.  To help in finding such an  instructions
  1541. the assembler will produce an error if it finds an odd destination
  1542. in a BSR or BRA operand. Note that such checks are not made on any
  1543. other  instructions,  so it is recommended that you  precede  such
  1544. labels  with  EVEN  directives if you require  them  to  be  word-
  1545. aligned.  A  common error is deliberately not to do this,  as  you
  1546. know  the preceding string is an even number of  bytes  long.  All
  1547. will be well until the day you change the string...
  1548.  
  1549. INSTRUCTION SET EXTENSIONS
  1550.      The  complete 68000 instruction set is supported and  certain
  1551. shorthands are automatically accepted,  detailed below. A complete
  1552. description of the instruction set including syntax and addressing
  1553. modes can be found in any 68000 reference guide or in the supplied
  1554. pocket guide.
  1555.  
  1556. CONDITION CODE
  1557. The altenate condition codes HS and LO are supported in Bcc, DBcc
  1558. and Scc instructions, equivalent to CC and CS, respectively.
  1559.  
  1560. BRANCH INSTRUCTIONS
  1561.      To force a short branch use Bcc.B or Bcc.S,  to force a  word
  1562. branch  use  Bcc.W or to leave the optimiser  use  Bcc.  Bcc.L  is
  1563. supported for compatibility with GenAm 1 with a warning as it  is,
  1564. strictly  speaking,   a  68020  instruction.   A  BRA.S  to   the
  1565. immediately following instruction is not allowed and is converted,
  1566. with  a warning,  to a NOP.  A BSR.S to the immediately  following
  1567. instruction is not allowed and will produce an error.
  1568.  
  1569. BTST INSTRUCTION
  1570.      BTST is unique among bit-test instructions in supporting  PC-
  1571. relative addressing modes.
  1572.  
  1573. CLR INSTRUCTION
  1574.      CLR An is not allowed,  use SUB.L An,An instead (though  note
  1575. that the flags are not affected).
  1576.  
  1577. CMP INSTRUCTION
  1578.      If  the source is immediate then CMPI is used,  else  if  the
  1579. destination is an address register then CMPA is used, else if both
  1580. addressing modes are post-incremented then CMPM is used.
  1581.  
  1582. DBcc INSTRUCTION
  1583.      DBRA is accepted as an equivalent to DBF.
  1584.  
  1585. ILLEGAL INSTRUCTION
  1586.      This generates the op-cope word $4AFC.
  1587.  
  1588. LINK INSTRUCTION
  1589.      If the displacement is positive or not even a warning is given.
  1590.  
  1591. MOVE FROM CCR INSTRUCTION
  1592.      This  is a 68010 and upwards instruction,  converted  with  a
  1593. warning to MOVE from SR.
  1594.  
  1595. MOVEQ INSTRUCTION
  1596.      If the data is in the range 128-255 inclusive a warning  will
  1597. be  given.  It  may be disabled by specifying a long size  on  the
  1598. instruction.
  1599.  
  1600. ASSEMBLER DIRECTIVES
  1601.      Certain  pseudo-mnemonics  are  recognised  by  GenIm.  These
  1602. assembler  directives,  as  they are called,  are  not  (normally)
  1603. decoded into opcodes, but instead direct the assembler time. These
  1604. actions have the effect of changing the object code  produced,  or
  1605. the  format of the listing.  Directives are scanned  exactly  like
  1606. executable  instructions and some may be preceded by a label  (for
  1607. some  it is obligatory) and may be followed by a comment.  If  you
  1608. put  a  label on a directive for which it  is  not  relevant,  the
  1609. result  will  be undefined but will usually result  in  the  label
  1610. being ignored.
  1611.      Each  directive will now be described in  turn.  Please  note
  1612. that  the case of a directive name is not important,  though  they
  1613. generally are shown in upper case. The use of angled brackets ( <> )
  1614. in descriptions denote optional  items,  ellipses  (  ...  )
  1615. denote repeated items.
  1616.  
  1617. ASSEMBLY CONTROL
  1618.  
  1619. END
  1620.      This directive signals that no more text is to be examined on
  1621. the current pass of the assembler. It is not obligatory.
  1622.  
  1623. INCLUDE filename
  1624.      This directive will cause source code to be taken from a file
  1625. on  disk  and assembled exactly as though it were present  in  the
  1626. text.  The  directive  must be followed by a  filename  in  normal
  1627. AmigaDOS format.
  1628.      If the filename has a space in it the name should be enclosed
  1629. in  single  or double quotes.  A drive  specifier,  directory  and
  1630. extension may be included as required, e.g.
  1631.  
  1632.      include b:constants/header.s
  1633.  
  1634.      Include  directives may be nested as deeply as memory  allows
  1635. and  if any error occurs when trying to open the file or read  it,
  1636. assembly will be aborted with a fatal error.
  1637.      If  no  drive or path name is specified,  that  of  the  main
  1638. source file will be used when trying to open the file.
  1639.  
  1640.      NOTE: The more memory the better, GenAm will read the whole of the
  1641. file in one go if it can and not bother to re-read the file during
  1642. pass 2.
  1643.  
  1644. INCDIR "directory"<,"directory" etc.>
  1645.      This directive specifies a list of directories that the include
  1646. directive should search in order to find each file. GenIm will append
  1647. each string onto the front of that given in the include directive. This
  1648. directive must appear before any include directives.
  1649.  
  1650. INCBIN    filename
  1651.      This  takes a given binary file and  includes  it,  verbatim,
  1652. into the output file.  Suggested uses include screen data,  sprite
  1653. date and ASCII files.
  1654.      The included data is forced to an even boundary and a single null
  1655. character is appended if the file is an odd number of bytes in length.
  1656.  
  1657. OPT       option <,option>...
  1658.      This  allows  control over various options within  GenAm  and
  1659. each one is denoted by a single character normally followed by a +
  1660. or - sign. Multiple options may be specified, separated by commas.
  1661. The allowed options are:
  1662.  
  1663. OPTION A - AUTOMATIC PC MODE ADDRESSING
  1664.      If OPT A+ is specified then GenAm will use PC mode addressing
  1665. where possible. For example:
  1666.  
  1667.           move.l    int_in,d0
  1668.  
  1669. will automatically be transformed into
  1670.  
  1671.           move.l    int_in(pc),d0
  1672.  
  1673. when assembled.
  1674.  
  1675.      Use of this option can significally reduce program size and
  1676. running time without a lot of extra typing. Please note however thit
  1677. it does not guarentee that the code generated will be position
  1678. independant.
  1679.      If you need to over-ride the automatic use of PC mode then use
  1680. the form (expression).l in a similar manner to that of short word
  1681. addressing as described above under labels and periods.
  1682.      So the example above could be forced to use absolutre addressing
  1683. by using the following:
  1684.  
  1685. move.l     (int_in).l,d0
  1686.  
  1687.     The default is A- when no such transformations are performed.
  1688.  
  1689. OPTION C - CASE SENSITIVITY AND SIGNIFICANCE.
  1690.      By default,  GenAm is sensitive to label case and labels  are
  1691. significant to 127 characters.  This can be overridden , using  C-
  1692. for case-sensitivity or C+ for case-insensitivity. The significan
  1693. ce  may be specified by specifying a decimal number between the  C
  1694. and  the sign,  for example C16+ denotes case  insensitive  labels
  1695. with  16 character significance.  This option may be used  at  any
  1696. time  in  a  program but normally only makes  sense  at  the  very
  1697. beginning of a source file.
  1698.  
  1699. OPTION D - DEBUGGING INFORMATION
  1700.      The  AmigaDOS  binary file format supports the inclusion of a
  1701. symbol hunk, which may be read by debuggers such  as
  1702. MONAm and  can be extremely useful when  debugging  programs.  By
  1703. default  this is switched off but it may be activated with D+  and
  1704. de-activated with D-. Normally all the relative symbols are included
  1705. in the file, but if OPT X+ is used in linkable mode then only the
  1706. exported (XDEF) symbols will be included.
  1707.  
  1708. OPTION L - LINKER MODE.
  1709.      The  default for GenAM is to produce executable code  but  L+
  1710. will  make it produce AmigaDOS linkable code, or L- will make it
  1711. revert to executable. This directive must be the very first line, in
  1712. the first text file.
  1713.  
  1714. OPTION M - MACRO EXPANSIONS.
  1715.      When an assembly listing is produced,  macro calls are  shown
  1716. in  the same form as in the source.  If you wish the  instructions
  1717. within  macros to be listed,  use M+,  while M- will  disable  the
  1718. option. You can use this directive as often as required. M- is the
  1719. default.
  1720.  
  1721. OPTION O - OPTIMISING.
  1722.      GenAM is capable of optimising certain statements to  faster
  1723. and  smaller versions.  By default all optimising is off but  each
  1724. type  can  be  abled and disabled as  required.  This  option  has
  1725. several forms:
  1726.  
  1727. OPT  O1+       will optimise backward branches to short if  within
  1728.                range, can be disabled with O1-.
  1729.  
  1730. OPT  O2+       will   optimise  address  register  indirect   with
  1731.                displacement addressing modes to addresss  register
  1732.                indirect,  if the displacemant evalues to zero, and
  1733.                can be disabled with O2-. For example,
  1734.  
  1735.           move.l   next(a0),d3
  1736.  
  1737. will be optimised to
  1738.  
  1739.           move.l   (a0),d3
  1740.  
  1741. If the value of next is zero.
  1742.  
  1743. OPT O+         will turn all optimising on.
  1744.  
  1745. OPT O-         will turn all optimising off.
  1746.  
  1747. OPT O1-, OPT O2-    will disable the relevant optimisation.
  1748.  
  1749. OPT OW-        will disable the warning messages generated by each
  1750.                optimisation, OW+ will enable them.
  1751.  
  1752.      If any optimising has been done during an assembly the number
  1753. of optimisations made and bytes saved will be shown at the end  of
  1754. assembly.
  1755.  
  1756. OPTION P - POSITION INDEPENDANT CHECKS.
  1757.      With  this  enabled with P+ GenAM will check  that  all  code
  1758. generated is position-independant,  generating errors on any lines
  1759. which require relocation.  It can be disabled with P- and defaults
  1760. to off.
  1761.  
  1762. OPTION S - SYMBOL TABLE
  1763.      When  a listing is turned on a symbol table will be  produced
  1764. at the end.  If you wish to change this S- will disable it,  while
  1765. S+ will re-enable it.  If you use this directive ore than once  the
  1766. last one will be taken into account.
  1767.  
  1768. OPTION T - TYPE CHECKING.
  1769.      GenST  can  often spot programming errors as  it  checks  the
  1770. types of certain expressions.  For some applications or styles  of
  1771. programming  this can be more of a hindrance than a  help.  So  T-
  1772. will  turn checks off.  T+ turning them back on.  For example  the
  1773. program segment
  1774.  
  1775.      main      bsr            initialise
  1776.                lea            main(a6),a0
  1777.                move.l         (main).w,a0
  1778.  
  1779.      will  normally  produce  an  error  as  main  is  a  relative
  1780. expression  where as the assembler expects an absolute  expression
  1781. in both cases.  However if this code is designed to run on another
  1782. 68000  machine this may be perfectly valid,  so the type  checking
  1783. should be disabled.
  1784.  
  1785. OPTION U - UNDERLINES FOR LOCAL LABELS
  1786.      Option U+ changes the character that introduces local tables to
  1787. be underline (_) rather than dat (.). Usa this if you need to use
  1788. labels beginning with dot for non-local labels.
  1789.  
  1790. OPTION W - WARNINGS
  1791.      If  you wish to disable the warnings that GenST can  produce,
  1792. you can do so with W-.  To re-enable them use W+.  This  directive
  1793. can be used as often as required.
  1794.  
  1795. OPTION X - EXPORTDEBUG
  1796.      This is a special version of option D which only outputs the
  1797. exported (XDEFed) symbols when producing linkable code. See the D
  1798. option above.
  1799.  
  1800. OPTION SUMMARY
  1801.      The  defaults  are  shown  in  brackets  after  each  options
  1802. description;
  1803.  
  1804. A    automatic PC mode addressing
  1805. C    case-sensitivity and significance (C127+)
  1806. D    include debugging info, (D-)
  1807. L-   produce executable code (default)
  1808. L+   produce GST linkable code
  1809. M    expand macros enlisting (M+)
  1810. O    optimising control (O-)
  1811. P    position independant code checks (P-)
  1812. S    symbol table listing
  1813. T    type checking (T+)
  1814. W    warning control (W+)
  1815. X    export debug (X-)
  1816.  
  1817. For example -   opt  m+,s+,w-
  1818.  
  1819. will  turn macro expansion on,  enable the symbol table  list  and
  1820. turn warnings off.
  1821.  
  1822. <label> EVEN
  1823.      This  directive  will force the program counter to  be  even,
  1824. i.e.   word  aligned.   As  GenAM automatically  word-aligns  all
  1825. instructions (except DC.Bs and DS.Bs).  It should not be  required
  1826. very often but can be useful for ensuring buffers and strings  are
  1827. word-aligned when required
  1828.  
  1829. CNOP      offset,alignment
  1830. This  directive  will align the program counter  using  the  given
  1831. offset  and alignment.  An alignment of 2 means  word-aligned,  an
  1832. alignment of 4 means long-word-aligned and so on. The alignment is
  1833. relative to the start of the current section. For example,
  1834.  
  1835.           cnop   1,4
  1836.  
  1837. aligns  the  program  counter  a  byte  past  the  next  long-word
  1838. boundary.
  1839.  
  1840.      Some parts of the Amiga operating system require certain items to
  1841. be longword aligned and this can be achieved with:
  1842.  
  1843.           cnop   0,4
  1844.  
  1845.      The start of a program and of each section is always guaranteed
  1846. to be longword aligned.
  1847.  
  1848. <label>   DC.B      expression<,expression> ...
  1849. <label>   DC.W      expression<,expression> ...
  1850. <label>   DC.L      expression<,expression> ...
  1851.  
  1852.      These  directives define constants in memory.  They may  have
  1853. one or more operands,  separated by commas.  The constants will be
  1854. aligned  on  word boundaries for DC.W and DC.L no  more  than  128
  1855. bytes can be generated by a single DC directive.
  1856.      DC.B  treats  strings slightly different to those  in  normal
  1857. expressions.  While the rules described previously about quotation
  1858. marks still applies.  No padding of the bytes will occur,  and the
  1859. length of any string can be upto 128 bytes.
  1860.      Be very careful of spaces in any DC directives, as a space is
  1861. the delimiter before a comment. For example, the line
  1862.  
  1863.           dc.b      1,2,3 ,4
  1864.  
  1865. will only generate 3 bytes - the ,4 will be taken as a comment.
  1866.  
  1867. <label>   DS.B      expression
  1868. <label>   DS.W      expression
  1869. <label)   DS.L      expression
  1870.  
  1871.      These  directives  will  reserve  memory  locations  and  the
  1872. contents will be initialised to zeros. If there is a label then it
  1873. will be set to the start of the area defined,  which will be on  a
  1874. word  boundary  for  DS.W  and  DS.L  directives.   There  is   no
  1875. restriction  on the size though the larger the area the longer  it
  1876. will take to save to disk.
  1877.  
  1878.       For example, all of these lines will reserve 8 bytes of space,
  1879. in different ways :
  1880.  
  1881.           ds.b 8
  1882.           ds.w 4
  1883.           ds.l 2
  1884.  
  1885. <label>   DCB.B     number,value
  1886. <label>   DCB.W     number,value
  1887. <label>   DCB.L     number,value
  1888.  
  1889.      This directive allows constant blocks of data to be generated
  1890. of the size specified,  number specifies how many times the  value
  1891. should be repeated.
  1892.  
  1893. FAIL
  1894.      This directive will produce the error user error.  It can  be
  1895. used  for  such things as warning the programmer if  an  incorrect
  1896. number of parameters have been passed to a macro.
  1897.  
  1898. OUTPUT    filename
  1899.      This directive sets the normal output filename though can  be
  1900. overridden by specifying a filename at the start of  assembly.  If
  1901. filename starts with a period then it is used as an extension  and
  1902. the output name is built up as described previously.
  1903.  
  1904. __G2      (reserved symbol)
  1905.      This is a reserved symbol that can be used to detect  whether
  1906. GenST is being used to assemble a file using the IFD  conditional.
  1907. The  value of this symbol depends on the version of the  assembler
  1908. and is always absolute.
  1909.  
  1910. REPEAT LOOPS
  1911.      It  is  often  useful  to  be able  to  repeat  one  or  more
  1912. instructions  a  particular number of times and  the  repeat  loop
  1913. construct allows this.
  1914.  
  1915. <label>   REPT      expression
  1916.           ENDR
  1917.  
  1918.      Lines to be repeated should be enclosed within REPT and  ENDR
  1919. directives  and will be repeated the number of times specified  in
  1920. the expression. If the expression is zero or negative then no code
  1921. will be generated.  It is not possible to nest repeat  loops.  For
  1922. example
  1923.  
  1924.           REPT      512/4             copy a sector quickly
  1925.           move.l    (a0)+,(a1)+
  1926.           ENDR
  1927.  
  1928.      NOTE: Program  labels should not be define within repeat  loops
  1929. to prevent label defined twice errors.
  1930.  
  1931. LISTING CONTROL
  1932.  
  1933. LIST
  1934.      This  will  turn the assembly listing on during  pass  2,  to
  1935. whatever  device was selected at the start of the assembly (or  to
  1936. the  screen of None was initially chosen).  All  subsequent  lines
  1937. will be listed until an END directive is reached,  the end of  the
  1938. text is reached, or a Nolist directive is encountered.
  1939.      Greater  control  over  listing sections of  program  can  be
  1940. achieved using LIST+ or LIST- directives. A counter is maintained,
  1941. the state of which dictates whether listing is on or off.  A LIST+
  1942. directive  adds one to the counter and a LIST- subtracts  one.  If
  1943. the  counter  is zero or positive then listing is  on,  if  it  is
  1944. negative  then listing is off.  The default starting value  is  -1
  1945. (i.e.  listing  off)  unless  a  listing  is  specified  when  the
  1946. assembler was invoked,  when it is set to zero. This system allows
  1947. a  considerable  degree of control over listing  particularly  for
  1948. include  files.  The normal LIST directive sets the counter to  0,
  1949. NOLIST sets it to -1.
  1950.  
  1951. NOLIST
  1952.      This will turn off any listing during pass 2.
  1953.  
  1954.      When  a listing is requested onto a printer or to  disk,  the
  1955. output is formatted into pages,  with a header at the top of every
  1956. page.  The header itself consists of a line containing the program
  1957. title, date, time and page number, then a line showing the program
  1958. title,  then a line showing the sub-title,  then a blank line. The
  1959. date  format  will be printed in the  form  DD/MM/YY,  unless  the
  1960. assembler  is  running  on a US Atari ST,  then  it  is  MM/DD/YY.
  1961. Between  pages  a  form-feed character (ASCII  FF,  value  12)  is
  1962. issued.
  1963.  
  1964. PLEN      expression
  1965.      This  will  set the page length of the assembly  listing  and
  1966. defaults to 60. The expression must be between 12 and 255.
  1967.  
  1968. LLEN      expression
  1969.      This  will  set the line width of the  assembly  listing  and
  1970. defaults  to 132.  The value of the expression must be between  38
  1971. and 255.
  1972.  
  1973. TTL       string
  1974.      This  will set the title printed at the top of each  page  to
  1975. the  given string,  which may be enclosed in  single  quotes.  The
  1976. first TTL directive will set the title of the first printed  page.
  1977. If  no  title is specified the current include file name  will  be
  1978. used.
  1979.  
  1980. SUBTTL    string
  1981.      Sets  the  subtitle printed at the top of each  page  to  the
  1982. given string,  which may be enclosed in single quotes.  The  first
  1983. such directive will set the sub-title of the first printed page.
  1984.  
  1985. SPC       expression
  1986.      This  will  output  the number of blank lines  given  in  the
  1987. expression in the assembly listing, if active.
  1988.  
  1989. PAGE
  1990.      Causes a new page in the listing to be started.
  1991.  
  1992. LISTCHAR  expression<,expression> ...
  1993.      This will send the characters specified to the listing device
  1994. (except  the  screen)  and is intended for doing  things  such  as
  1995. setting  condensed mode on printers.  For example,  on Epsons  and
  1996. compatibles the line
  1997.  
  1998.           listchar  15
  1999.  
  2000. will set the printer to 132-column mode.
  2001.  
  2002. FORMAT    parameter<,parameter> ...
  2003.      This allows exact control over the listed format of a line of
  2004. source  code.  Each parameter controls a field in the listing  and
  2005. must consist of a digit from 0 to 2 inclusive followed by a +  (to
  2006. enable the field) or a - (to disable it):
  2007.  
  2008. 0    line number, in decimal
  2009. 1    section name/number and program counter
  2010. 2    hex data words, up to 10 words unless printer is less than 80
  2011.      characters wide, when up to three words are listed.
  2012.  
  2013. LABEL DIRECTIVES
  2014.  
  2015. label     EQU       expression
  2016.  
  2017.      This directive will set the value and type of the given label
  2018. to  the  results of the expression.  It may  not  include  forward
  2019. references,  or  external  labels.  If there is any error  in  the
  2020. expression,  the  assignment  will  not  be  made.  The  label  is
  2021. compulsory and must not be a local label.
  2022.  
  2023. label     =         expression
  2024.  
  2025. Alternate form of EQU statement
  2026.  
  2027. label     EQUR      register
  2028.  
  2029.      This  directive  allows  a data or  address  register  to  be
  2030. referred  to  by  a  user-name,  supplied as  the  label  to  this
  2031. directive.  This is known as a register equate.  A register equate
  2032. must be defined before it is used.
  2033.  
  2034. label     SET       expression
  2035.  
  2036.      This is similar to EQU,  but the assignment is only temporary
  2037. and  can  be  changed with a  subsequent  SET  directive.  Forward
  2038. references  cannot  be used in the expression.  It  is  especially
  2039. useful for counters within macros, for example, using a line
  2040.  
  2041. zcount    set       zcount+1
  2042.  
  2043. (assuming zcount is set to 0 at the start of the source).  At  the
  2044. start of pass 2 all SET labels are made undefined, so their values
  2045. will always be the same on both passes
  2046.  
  2047. label     REG       register-list
  2048.  
  2049.      This  allows  a symbol to be used to denote a  register  list
  2050. within MOVEM instructions,  reducing the likelihood of having  the
  2051. list at the start of a routine different from the list at the  end
  2052. of the routine. A label defined with REG can only be used in MOVEM
  2053. instructions.
  2054.  
  2055. <label>   RS.B      expression
  2056. <label>   RS.W      expression
  2057. <label>   RS.L      expression
  2058.  
  2059.      These  directives  let you set up lists of  constant  labels,
  2060. which is very useful for data structures and global variables  and
  2061. is best illustrated by a couple of examples
  2062.      Let's  assume you have a data structure which consists  of  a
  2063. long word,  a byte and another long word,  in that order.  To make
  2064. your code more readable and easier to update should the  structure
  2065. change, you could use lines such as:
  2066.  
  2067.           rsreset
  2068. d_next    rs.l      1
  2069. d_flag    rs.b      1
  2070. d_where   rs.l      1
  2071.  
  2072. and then you could access them with lines like
  2073.  
  2074.           move.l    d_next(a0),a1
  2075.           move.l    d_where(a0),a2
  2076.           tst.b     d_flag(a0)
  2077.  
  2078. As  another  example  let's assume you are  referencing  all  your
  2079. variables  off register A6 (as done in GenAM and MonAM) you  could
  2080. define them with lines such as
  2081.  
  2082. onstate   rs.b      1
  2083. start     rs.l      1
  2084. end       rs.l      1
  2085.  
  2086. you then could reference them with lines such as
  2087.  
  2088.           move.b    onstate(a6),d1
  2089.           move.l    start(a6),d0
  2090.           cmp.l     end(a6),d0
  2091.  
  2092.      Each such directive uses its own internal counter, which is reset
  2093. to 0 at the beginning of each pass. Every time the assembler comes
  2094. across  the directive it sets the label according to  the  current
  2095. value  (with word alignment if it is .W or .L) then increments  it
  2096. according to the size and magnitude of the directive. If the above
  2097. definitions  were  the first RS directives,  onstate would  be  0,
  2098. start would be 2 and end would be 6.
  2099.  
  2100. RSRESET
  2101.      This directive will reset the internal counter as used by the RS
  2102. directive.
  2103.  
  2104. RSSET     expression
  2105.      This allows the RS counter to be set to a particular value.
  2106.  
  2107. __RS      (reserved symbol)
  2108.      This is a reserved symbol having the current value of the RS
  2109. counter.
  2110.  
  2111. CONDITIONAL ASSEMBLY
  2112.      Conditional  assembly  allows  the  programmer  to  write   a
  2113. comprehensive  source  program  that can  cover  many  conditions.
  2114. Assembly  conditionals  may  be  specified  through  the  use   of
  2115. arguments,  in the case of macros,  and through the definition  of
  2116. symbols  in EQU or SET directives.  Variations in these  can  then
  2117. cause  assembly  of only those parts necessary for  the  specified
  2118. conditions.
  2119.      There   are  a  wide  range  of  directives  concerned   with
  2120. conditional assembly. At the start of the conditional blocks there
  2121. must  be  one of many IF directives and at the end of  each  block
  2122. there must be an ENDC directive.  Conditional blocks may be nested
  2123. up to 65535 levels.
  2124.      Labels  should not be placed on IF or ENDC directives as  the
  2125. directives will be ignored by the assembler.
  2126.  
  2127.           IFEQ      expression
  2128.           IFNE      expression
  2129.           IFGT      expression
  2130.           IFGE      expression
  2131.           IFLT      expression
  2132.           IFLE      expression
  2133.  
  2134.      These directives will evaluate the expression, compare it with
  2135. zero and then turn the conditional assembly on or off depending on
  2136. the  result.  The  conditions  correspond  exactly  to  the  68000
  2137. condition codes.  For example, if the label DEBUG had the value 1,
  2138. then with the following code,
  2139.  
  2140.           IFEQ DEBUG
  2141. logon     dc.b      'enter a command:'.0
  2142.           ENDC
  2143.           IFNE DEBUG
  2144.           opt       d+        labels please
  2145. logon     dc.b      'Yeah, gimme man:',0
  2146.           ENDC
  2147.  
  2148. the first conditional would turn assembly off as 1 is not EQ to 0,
  2149. while the second conditional would turn it on as 1 is NE to 0.
  2150.  
  2151.      NOTE: IFNE corresponds to IF in assemblers with only one
  2152. conditional directive.
  2153.      The  expressions  used in these conditional  statements  must
  2154. evaluate correctly.
  2155.  
  2156. IFD       label
  2157. IFND      label
  2158.      These  directives  allow  conditional  control  depending  on
  2159. whether a label is defined or not.  With IFD, assembly is switched
  2160. on if the label is defined, whereas with IFND assembly is switched
  2161. on  if the label is not defined.  These directives should be  used
  2162. with  care otherwise different object codes could be generated  on
  2163. pass  1 and pass 2 which will produce incorrect code and  generate
  2164. phasing errors. Both directives also work on reserved symbols.
  2165.  
  2166. IFC       'string1','string2'
  2167.      This  directive will compare two strings,  each of which  must
  2168. be surrounded  by single quotes.  If they are identical  assembly  is
  2169. switched  on,  else  it i switched off.  The  comparison  is  case
  2170. sensitive.
  2171.  
  2172. IFNC      'string1','string2'
  2173.      This directive is similar to the above, but only switches
  2174. assembly on  if  the strings are not identical.  This may at  first
  2175. appear somewhat useless, but when one or both of the parameters are
  2176. macro parameters it can b every useful, as shown in the next section.
  2177.  
  2178. ELSEIF
  2179.      This  directive toggles conditional assembly from on  to  off,
  2180. or vice versa.
  2181.  
  2182. ENDC
  2183.      This  directive  will terminate the current level  of
  2184. conditional assembly.  If  there  are more IF's then ENDC's an error
  2185. will be reported at the end of assembly.
  2186.  
  2187. IIF       expression   instruction
  2188. This  is  a  short form of the IFNE directive  allowing  a  single
  2189. instruction  or directive to be assembled conditionally.  No  ENDC
  2190. should be used with IIF directives.
  2191.  
  2192. MACRO OPERATIONS
  2193.      GenAM fully supports Motorola-style macros, which together with
  2194. conditional  assembly  allows you greatly  to  simplify  assembly-
  2195. language programming and the readability of your code.
  2196.      A macro is a way for a programmer to specify a whole sequence
  2197. of  instructions  or  directives  that  are  used  together   very
  2198. frequently. A macro is first defined, then its name can be used in
  2199. a macro call like a directive with up to 36 parameters.
  2200.  
  2201. label     MACRO
  2202.      This starts a macro definition and causes GenAM to copy all
  2203. following  lines  to  a macro buffer until an  ENDM  directive  is
  2204. encountered. Macro definitions may not be nested.
  2205.  
  2206. ENDM
  2207.      This terminates the storing of a macro definition, after a  MACRO
  2208. directive.
  2209.  
  2210. MEXIT
  2211.      This stops prematurely the current macro expansion and is best
  2212. illustrated by the INC example given later.
  2213.  
  2214. NARG      (reserved label)
  2215.      This is not a directive but a reserved symbol, Its value is  the
  2216. number  of parameters passed to the current macro,  or 0  if  used
  2217. when not within any macro.  If GenAM is in the case sensitive mode
  2218. then the name should be all upper-case.
  2219.  
  2220. MACRO PARIMETERS
  2221.      Once a macro has been defined with the Macro directive it can
  2222. be invoked by using its name as a directive,  followed by upto  36
  2223. parameters.  In the macro itself the parameters may be referred to
  2224. by  using a backslash character (\) followed by  an  alpha-numeric
  2225. (1-9,  A-Z  or  a-z)  which will be  replaced  with  the  relevant
  2226. parameter when expanded or with nothing if no parameter was given.
  2227. There  is  also the special macro parameter \0 which is  the  size
  2228. appended to the macro call and defaults to W if none is given.  If
  2229. a  macro  parameter  is  to include  spaces  or  commas  then  the
  2230. parameter should be enclosed in between < and > symbols;  in  this
  2231. case  a  >  symbol  may  be  included  within  the  parameters  by
  2232. specifying >>.
  2233.      A special form of macro expansion allows the conversion of  a
  2234. symbol to a decimal or hexadecimal sequence of digits,  using  the
  2235. syntax \<symbol> or \$<symbol>, the latter denoting hex expansion.
  2236. The symbol mast be defined and absolute at the time of expansion.
  2237.      The  parameter \@ can be useful for generating unique  labels
  2238. with each macro call and is replaced when the macro is expanded by
  2239. the  sequence  _nnn where nnn is a number which increases  by  one
  2240. with  every  macro call.  It may be expanded up to  5  digits  for
  2241. very large assemblies.
  2242.      A true \ may be included in a macro definition by specifying \\.
  2243.  
  2244.      A  macro  call  may  be  spread  over  more  than  one  line,
  2245. particularly  useful for macros with large numbers of  parameters.
  2246. This  can  be  done  by ending a macro  call  with  a  comma  then
  2247. starting  the next line with an & followed by tabs or spaces  then
  2248. the continuation of the parameters.
  2249.      In the assembly listing the default is to show just the macro
  2250. call and not the code produced by it. However, macro expansion
  2251. listings can  be  switched on and off using the OPT M  directive
  2252. described previously.
  2253.      Macro  calls may be nested as deeply as memory  permits,
  2254. allowing recursion if required.
  2255.      Macro  names are stored in a separate symbol table to normal
  2256. symbols so will not clash with similarly named routines,  and  may
  2257. start with a period.
  2258.  
  2259. MACRO EXAMPLES
  2260.  
  2261. EXAMPLE 1 - CALLING A LIBRARY
  2262.      As the first example, a common way of calling an Amiga library
  2263. routine is:
  2264.  
  2265.         save register a6
  2266.         load a6 from a library pointer
  2267.         do a jsr with offset
  2268.         restore a6
  2269.  
  2270.      A macro to follow the above specifications could be:
  2271.  
  2272. call_lib MACRO
  2273.          move.l   a6,-(sp)
  2274.          move.l   \2,a6       get lib pointer
  2275.          jsr      _LVO\l(a6)  call it
  2276.          move.l   (sp)+,a6    restore
  2277.          ENDM
  2278.  
  2279.      The directives are in capitals only to make them stand  out:  they
  2280. don't have to be.  If you wanted to call this macro to use the DOS
  2281. function Output the code would be:
  2282.  
  2283. call_lib Output,_DOSbase
  2284.  
  2285.      When this macro call is expanded, \1 is replaced with Output and
  2286. \2 is replaced with _DOSbase. \0, if it occurred in the macro, would
  2287. be W as no size  is given on the call.  So the above call would be
  2288. assembled as:
  2289.  
  2290.         move.l  a6,-(sp)
  2291.         move.l  _DOSbase,a6     get lib pointer
  2292.         jsr     _LVOOutput(a6)  call it
  2293.         move.l  (sp)+,a6        restore a6
  2294.  
  2295. EXAMPLE 2 - AN INC INSTRUCTION
  2296.      The 68000 does not have the INC instruction like other
  2297. processors but the same effect can be achieved using an ADDQ #1
  2298. instruction. A macro may be used to do this, like so:
  2299.  
  2300. inc       MACRO
  2301.           IFC       '','\1'
  2302.           fail      missing parameter!
  2303.           MEXIT
  2304.           ENDC
  2305.           addq.\0   #1,\1
  2306.           ENDM
  2307.  
  2308. An example call would be
  2309.  
  2310.           inc.1     a0
  2311.  
  2312. which would expand to
  2313.  
  2314.           addq.1    #1,a0
  2315.  
  2316.      The macro starts by comparing the first parameter with an empty
  2317. string and causing an error message to be issued using FAIL if  it
  2318. is equal.  The MEXIT directive is used to leave the macro  without
  2319. expanding the rest of it.  Assuming there is a non-null parameter,
  2320. the next line does the ADDQ instruction, using the \0 parameter to
  2321. get the correct size.
  2322.  
  2323. EXAMPLE 3 - A FACTORIAL MACRO
  2324.      Although  unlikely actually to be used as it stands, this macro
  2325. defines  a  label to be the factorial of a number.  It  shows  how
  2326. recursion  can work in macros.  Before showing the  macro,  it  is
  2327. useful to examine how the same thing would be done in a high level
  2328. language such as Pascal.
  2329.  
  2330. function  factor(n:integer):integer;
  2331. begin
  2332.           if n>0 then
  2333.                     factor:=n*factor(n-1)
  2334.           else
  2335.                     factor:=1
  2336. end;
  2337.  
  2338.      The macro definition for this uses the SET directive to do the
  2339. multiplication n*(n-1)*(n-2) etc. in this way
  2340.  
  2341. *    parameter 1= label,   parameter 2= 'n'
  2342. factor    MACRO
  2343.           IFND      \1
  2344. \1        set       1         set if not yet defined
  2345.           ENDC
  2346.           IFGT      \2
  2347.           factor    \1,\2-1   work out next level down
  2348. \1        set       \1*(\2)   n = n * factor(n-1)
  2349.           ENDC
  2350.           ENDM
  2351. *    a sample call
  2352.           factor test,3
  2353.  
  2354.      The net result of the previous code is to set test to 3! (3
  2355. factorial). The reason the second set  has (\2) instead of just \2
  2356. is  that  the  parameter  will  not  normally  be  just  a  simple
  2357. expression,  but a list of numbers separated by minus signs, so it
  2358. could assemble to:
  2359.  
  2360. test      set       test*5-1-1-1
  2361.  
  2362. (i.e. test*5-3) instead of the correct
  2363.  
  2364. test      set       test*(5-1-1-1)
  2365.  
  2366. (i.e. test *2)
  2367.  
  2368. EXAMPLE 4 - CONDITIONAL RETURN INSTRUCTION
  2369.      The 68000 lacks the conditional return instruction found on other
  2370. processors,  but macros can be defined to implement them using the
  2371. \@ parameter. For example, a return if EQ macro could look like:
  2372.  
  2373. rtseq     MACRO
  2374.           bne.s     \@
  2375.           rts
  2376. \@
  2377.           ENDM
  2378.  
  2379.       The \@ parameter has been used to generate a unique label every
  2380. time  the macro is called,  so will generate in this  case  labels
  2381. such as _002 and _017.
  2382.  
  2383. EXAMPLE 5 - NUMERIC SUBSTITUTION
  2384.      Suppose you have a constant containing the version number of
  2385. your program and wish it to appear as ASCII in a message:
  2386.  
  2387. showname  MACRO
  2388.           dc.b      \1,'\<version>',0
  2389.           ENDM
  2390.           .
  2391.           .
  2392. version   equ       42
  2393.           showname  <'Real Ale Search Program v'>
  2394.  
  2395. will expand to the line
  2396.  
  2397.           dc.b      'Real Ale Search Program v','42',0
  2398.  
  2399. Note  the  way  the string parameter is enclosed in  <  >s  as  it
  2400. contains spaces.
  2401.  
  2402. EXAMPLE 6 - COMPLEX MACRO CALL
  2403.      Suppose your program needs a complicated table structure which
  2404. can have a varying number of fields.  A macro can only be written  to
  2405. using those parameters that are specified,  for example:
  2406.  
  2407. table_entry         macro
  2408.           dc.b      .end\0-*            length byte
  2409.           dc.b      \1                  always
  2410.           IFNC      '\2',''
  2411.           dc,w      \2,\3               2nd and 3rd together
  2412.           ENDC
  2413.           dc.l      \4,\5,\6,\7
  2414.           IFNC      '\8',''
  2415.           dc.b      '\8'                text
  2416.           ENDC
  2417.           dc.b      \9
  2418. .end\@    dc.b      0
  2419.           ENDM
  2420.  
  2421. * a sample call
  2422.           table_entry                   &42,,,t1,t2,t3,t4,
  2423. &                                       <Enter Name:>,%0110
  2424.  
  2425. NOTE: THE NEXT 2 PAGES ARE MISSING FROM MY PHOTOCOPY (THANX REB!) SO
  2426. I'LL HAVE TO IMPROVISE.. I'LL MARK WHERE IT'S BACK FROM THE MANUAL.
  2427.  
  2428.      This is a non-trivial example of how macros can make a
  2429. programmer's  life so much easier when dealing with  complex  data
  2430. structures.  In  this  case the table consists of a  length  byte,
  2431. calculated in the macro using \@,  two optional words, four longs,
  2432. an optional string, a byte, then a zero byte. The code produced in
  2433. this example would be :
  2434.  
  2435.           dc.b      .end_001
  2436.           dc.b      $42
  2437.           dc.l      t1,t2,t3,t4
  2438.           dc,b      'Enter Name:'
  2439.           dc,b      %0110
  2440. .end_001  dc.b      0
  2441.  
  2442. OUTPUT FILE FORMATS
  2443.      GenAM is very flexible in terms of output file formats. These
  2444. are detailed in this section together with notes on the advantages
  2445. and  disadvantages  of each.  Certain  directives  take  different
  2446. actions, depending on what output file format is specified.
  2447.  
  2448.      The exact details of using each format will now be described.
  2449.  
  2450. EXECUTABLE FILES
  2451.      These  are  directly  executable,   for  example,  by  double
  2452. clicking  from the workbench, or from the CLI. The file may include
  2453. relocation information  and/or symbolic information.
  2454.  
  2455. ADVANTAGES
  2456.      true BSS sections, reduced development time.
  2457.  
  2458. DISADVANTAGES
  2459.      messy if more than one programmer.
  2460.  
  2461. GST LINKABLE FILES
  2462.      When  writing  larger programs,  or  when  writing  assembly
  2463. language  modules  for  use  from  the  high  level  language,   a
  2464. programmer needs to generate a linkable file.  The GST link format
  2465. is  supported  by  most of the high level  languages  produced  in
  2466. Britain as well as others,  for example HiSoft Basic,  Lattice  C,
  2467. Prospero  Fortran and Prospero Pascal.  GST format files  normally
  2468. have the extension .BIN.
  2469.  
  2470. ADVANTAGES
  2471.      Great  degree of freedom - imported labels  can  be
  2472. used  practically anywhere including within arbitrary  expressions,
  2473. libraries can be created from the assembler,  import methods means
  2474. the assembler can detect type conflicts.
  2475.  
  2476. DISADVANTAGES
  2477.      Library format means selective library linking  can
  2478. be  slow,  true AmigaDOS sections not supported as standard.
  2479.  
  2480. CHOOSING THE RIGHT FILE FORMAT
  2481.      If  you wish to link with a high level language  there  isn't
  2482. usually  much  choice  -  you have  to  use  whichever  format  is
  2483. supported by the language.
  2484.      If  you  are writing entirely in assembly language  then  the
  2485. normal  choice has to be executable - it is fast to  assemble,  no
  2486. linking  required,  and  allows assembly to memory  for  decreased
  2487. development time.
  2488.      If  you  are writing a larger program,  say bigger  than  32k
  2489. object,  or writing a program as a team,  then linkable code often
  2490. makes  most sense.  We recommend GST-linkable over DRI because  of
  2491. the much greater flexibility of the format.
  2492.  
  2493. OUTPUT FILE DIRECTIVES
  2494.      This section details those directives whose actions depend on
  2495. the  output  file format chosen.  The file format  itself  can  be
  2496. chosen by one of the following methods; command line options using
  2497. GENST2.TTP;  clicking on the radio buttons in the Assembly Options
  2498. dialogue box from the editor,  or with the OPT L directive at  the
  2499. beginning of the source file.
  2500.  
  2501. Icons are used to denote those sections specific to a file format,
  2502. viz
  2503.  
  2504. *EXEC*    Executable-code, also assembled to memory code.
  2505.  
  2506. *GST*     GST-linkable code
  2507.  
  2508. *DRI*     DRI-linkable code.
  2509.  
  2510. BACK TO THE MANUAL, HOPE I GOT IT RIGHT, shit! THE NEXT BIT IS VERY
  2511. DIFFERANT SO THE ABOVE IS PROBABLY WRONG!           PARASITE 4.26am
  2512.  
  2513. SECTIONS
  2514.  
  2515. SECTION string<,type>
  2516.      This  defines a switch to the named section and optionally
  2517. defines it's type. A program may consist of several sections which
  2518. will be concentrated together with other sections of the same name in
  2519. the final executable file. This will use the supplied string and type
  2520. as the section name and type of this section (of hunk) respectivly.
  2521. Each can be up to 32 characters long and should not include tabs or
  2522. spaces or be enclosed in quotes. The casing of the name is
  2523. significant. You may have many SECTION directives in your program.
  2524.      The type can be one of the following (in upper or lower case):
  2525.  
  2526. CODE    code section, public memory
  2527. CODE_F  code section, Fast memory
  2528. CODE_C  code section, chip memory
  2529. DATA    data section, public memory
  2530. DATA_F  data section, fast memory
  2531. DATA_C  data section, chip memory
  2532. BSS     BSS section, public memory
  2533. BSS_F   BSS section, fast memory
  2534. BSS_C   BSS section, chip memory
  2535.  
  2536.      CODE sections are used for executable instructions, DATA sections
  2537. for initialised data (constants), and BSS for un-initialised data. BSS
  2538. sections  have the advantage that they take no disk space - only the
  2539. length of the BSS section is stored. If you define a section to be BSS
  2540. you can only use the directive to produce code - any other code
  2541. generating instructions will cause a binary file i/o error.
  2542.      NOTE: Do not use types requesting chip or fast memory, with
  2543. versions prior to version 2.3 of the Alink linker - these versions
  2544. will crash!
  2545.  
  2546. CODE/DATA/BSS
  2547.      These directives are supported for compatability with the Amiga
  2548. macro assembler. They are the same as specifying the directive as the
  2549. section name and type.
  2550.  
  2551. IDNT string
  2552.      This will use the supplied name as the hunk unit name for this
  2553. section, It can be up to 32 characters long and should not include
  2554. tabs or spaces or be enclosed in quotes.
  2555.  
  2556. IMPORTS AND EXPORTS
  2557.      With both linkable types of program it is crucial to be  able
  2558. to import and export symbols,  both relative symbols (i.e. program
  2559. references) and absolute symbols (i.e.  constants). The AmigaDOS
  2560. linker format does not distinguish between these types; however by
  2561. specifying the type when importing, the assembler can type check,
  2562. often  finding programming errors that would otherwise be missed.
  2563.  
  2564. XDEF      export<,export>...
  2565.      This  defines  labels  for  export  to  other  programs   (or
  2566. modules).  If any of the labels specified are not defined an error
  2567. will occur. It is not possible to export local labels.
  2568.  
  2569. EXEC
  2570.      This directive is ignored
  2571.  
  2572. XREF      import<,import>...
  2573. XREF.L    import<,import>...
  2574.      This  defines  labels to be imported from other  programs  or
  2575. modules.  If any of the labels specified are defined an error will
  2576. occur.  The  normal  XREF  statement should be used  to  import  a
  2577. relative label (i.e.  program reference),  while XREF.L should  be
  2578. used to import absolute labels (i.e. constants). If you do not type
  2579. your imports you should turn type-checking off using OPT T-
  2580.      Importing a label more than once will not produce an error.
  2581.  
  2582. EXEC
  2583.      This directive is ignored
  2584.  
  2585. USING IMPORTS IN EXPRESSIONS
  2586.  
  2587. EXEC
  2588.      There are no imports! However referances to labels in other
  2589. sections are subject to the limitations described below.
  2590.  
  2591. LINK
  2592.      Imports  may be used in expressions but only one  import
  2593. per  expression is allowed.  The results of an expression with  an
  2594. import  in must be of the form import+number  or  import-number.
  2595. Imports can be combined with arbitrarily complex  expressions,  so
  2596. long as the complex expression lexically precedes it, for example
  2597.  
  2598.           move.l    3+(1<<count+5)+import
  2599.  
  2600. EXPRESSION     GST            DRI       EXAMPLE
  2601. byte           Y              N         move.b #test,do
  2602. word           Y              Y         move.w test(a3),d0
  2603. long           Y              Y         move.l test,d0
  2604.  
  2605. COMMENT   comment string
  2606.  
  2607. This directive is ignored at present
  2608.  
  2609. ORG       expression
  2610.      This will make the assembler generate position dependant code
  2611. and  set  the program counter to the given  value.  Normal AmigaDOS
  2612. program,s do not need an ORG statement even if position dependant.
  2613. It  is included to allow code to be generated for the ROM port  or
  2614. for other 68000 machines.  More than one ORG statement is  allowed
  2615. in a source file but no padding of the file is done.
  2616.  
  2617. EXEC
  2618.      It  should  be used with great care as the  binary  file
  2619. generated will probably not execute correctly when double clicked.
  2620. as  no  relocation information is written  out.  The  binary  file
  2621. produced  has  the standard AmigaDOS header at  the  front,  but  no
  2622. relocation information.
  2623.  
  2624. LINK
  2625.      This directive is not allowed.
  2626.  
  2627. OFFSET    <expression>
  2628.      This  switches  code  generation  to  a  special  section  to
  2629. generate absolute labels. The optional expression sets the program
  2630. counter for the start of this section. No bytes are written to the
  2631. disk and the only code generating directive allowed is DS.  Labels
  2632. defined in this section will be absolute.  For example,  to define
  2633. some of the system variables of the ST. (This is in the AMIGA
  2634. manual!);
  2635.  
  2636.           offset    $400
  2637. etv_timer           ds.l      1         will be $400
  2638. etv_critic          ds.l      1         404
  2639. etv_term            ds.l      1         408
  2640. ext_extra           ds.l      5         40C
  2641. memvalid            ds.l      1         420
  2642. memcntlr            ds.w      1         424
  2643.  
  2644. __LK      (reserved symbol)
  2645.      This  is a reserved symbol that can be used to  detect  which
  2646. output  mode  is specified.  The value of this symbol  is  alwayus
  2647. absolute and one of the following:
  2648.  
  2649. 3 linkable
  2650. 4 executable
  2651.  
  2652.       Values 0-2 are reserved for the production of ST code; other
  2653. values and the high word are reserved for future expansion.
  2654.  
  2655. RETURN CODES
  2656.      When using the stand alone assembler from within batch files or
  2657. make files, it's return code can be used to determine  the success of
  2658. the assembly. Values returned are:
  2659.  
  2660. 100+ initialisation failure
  2661.  20  fatal error
  2662.   5  warnings
  2663.   0  OK
  2664.  
  2665. DIRECTIVE SUMMARY
  2666.  
  2667. ASSEMBLY CONTROL
  2668. END       terminate source code
  2669. INCLUDE   read source file from disk
  2670. INCBIN    read binary file from disk
  2671. OPT       option control
  2672. EVEN      ensure PC even
  2673. CNOP      align PC arbitrarily
  2674. DC        define constant
  2675. DS        define space
  2676. DCB       define constant block
  2677. FAIL      force assembly error
  2678.  
  2679. REPEAT LOOPS
  2680. REPT      start repeat block
  2681. ENDR      end repeat block
  2682.  
  2683. LISTING CONTROL
  2684. LIST      enable list
  2685. NOLIST    disable list
  2686. PLEN      set page length
  2687. LLEN      set line length
  2688. TTL       set title
  2689. SUBTTL    set sub-title
  2690. PAGE      start new page
  2691. LISTCHAR  send control character
  2692. FORMAT    define listing format
  2693.  
  2694. LABEL DIRECTIVES
  2695. EQU       define label value
  2696. EQUR      define register equate
  2697. SET       define label value temporarily
  2698. REG       define register list
  2699. RS        reserve space
  2700. RSRESET   reset RS counter
  2701. RSSET     set RS counter
  2702.  
  2703. CONDITIONAL ASSEMBLY
  2704. IFEQ      assemble if zero
  2705. IFNE      assemble in non-zero
  2706. IFGT      assemble if greater than
  2707. IFGE      assemble if greater than or equal to
  2708. IFLT      assemble if less than
  2709. IFLE      assemble if less than or equal to
  2710. IFD       assemble if label defined
  2711. IFND      assemble if label not defined
  2712. IFC       assemble if strings same
  2713. IFNC      assemble if strings different
  2714. ELSEIF    switch assembly state
  2715. IIFC      immediate IF
  2716.  
  2717. MACROS
  2718. MACRO     define macro
  2719. ENDM      end macro definition
  2720.  
  2721. OUTPUT FILE DIRECTIVES
  2722. MODULE    start new module
  2723. SECTION   switch section
  2724. XDEF      define label for export
  2725. XREF      define label for import
  2726. COMMENT   send linker comment
  2727. ORG       set absolute code generation
  2728. OFFSET    define offset table
  2729.  
  2730. RESERVED SYMBOLS
  2731. NARG      number of macro parameters
  2732. __G2      internal version number
  2733. __RS      RS counter
  2734. __LK      output file type
  2735.  
  2736. BLINK LINKER
  2737.      This version of BLINK is a public domain limker designed as a
  2738. replacement for the standard AmigaDOS linker, Alink. The program has
  2739. many powerful features, but in the simplest case the command line is
  2740.  
  2741. blink (from) <infile.o> [<infile2.o>...] [ TO <outfile>]
  2742.  
  2743. which specifies one or more input files and an output file. Normally
  2744. all sections will be placed in seperate hunks, but they can be forced
  2745. into one hunk by specifying SMALLCODE or SMALLDATA on the command
  2746. line. For example;
  2747.  
  2748. blink test.o
  2749.  
  2750. will link test.o into the file test
  2751.  
  2752. blink FROM start.o middle.o end.o TO total
  2753.  
  2754. will link the specified three files into total
  2755.  
  2756. blink FROM start.o middle.o end.o TO total SMALLCODE
  2757.  
  2758. as above but coalescing for BLink are contained in a  file on disk 2,
  2759. which can be read on screen or printed out in the usual manor.
  2760.  
  2761.  
  2762.  
  2763. CHAPTER 4: SYMBOLIC DEBUGGER
  2764.  
  2765. INTRODUCTION
  2766.      Programs written in assembly language are particularly error-
  2767. prone  because  even a slight mistake can result  in  the  entire
  2768. machine crashing.  There are various forms of bugs,  ranging from
  2769. the trivial (e.g.  a missing CR in a printout),  though the usual
  2770. (e.g.  an incorrect result_ to the very serious (e.g. the machine
  2771. completely hanging, perhaps with a weird display).
  2772.      To help you find and correct all forms of bugs, Devpac includes
  2773. MonAm.  MonST is a symbolic debugger and disassembler which  lets
  2774. you examine programs and memory,  execute programs an instruction
  2775. at  a  time and trap processor exceptions  caused  by  programmer
  2776. error. As MonAm is symbolic you can look at your program complete
  2777. with all the original labels,  making debugging very much  easier
  2778. than having to battle with 6-digit hex numbers (or 8 digits on the
  2779. 68020!).
  2780.      Although MonAm is a low-level debugger, displaying such things as
  2781. 68000 instructions and bytes of memory,  it can also be used  for
  2782. debugging  programs  written  with any  compiler  that  generates
  2783. machine-code output.  If the compiler has the option to dump  the
  2784. symbols into the binary code then you will see your procedure and
  2785. function  names  within  the code,  and you can  even  view  your
  2786. original  source  code.
  2787.      As MonAm uses its own screen (in the Amiga sense), if you are
  2788. debugging a program with windows your program will not be sent re-draw
  2789. messages whilst you are using the debugger. Many other Amiga debuggers
  2790. do send these messages - it can be very confusing.
  2791.  
  2792. EXCEPTIONS
  2793.      MonAm uses the 68000 processor exceptions to stop runaway
  2794. programs and to single-step,  so at this point it would be useful
  2795. to  explain them and what normally happens when they occur on  an
  2796. Amiga.
  2797.      There are various types of exception that can  occur,  some
  2798. deliberately,  others  accidentally.  When  one  does  occur  the
  2799. processor saves some information on the SSP, goes into Supervisor
  2800. mode and jumps to an exception handler. On the Amiga these normally
  2801. produce a software error tash held system requester, or the dreaded
  2802. guru, but when MonAM is active it re-directs  some of these exceptions
  2803. so it can take control  when they occur. The various forms of
  2804. exceptions, their usual results, and  what happens when they occur
  2805. with MonAm active is  shown  in the following table:
  2806.  
  2807.   No.   EXCEPTION              MONAM ACTIVE
  2808.    2    bus error              trapped
  2809.    3    address error          trapped
  2810.    4    illegal instruction    trapped
  2811.    5    zero divide            trapped
  2812.    6    CHK instruction        trapped
  2813.    7    TRAPV instruction      trapped
  2814.    8    privilege violation    trapped
  2815.    9    trace                  single stepping
  2816.   10    line 1010 emulator     trapped
  2817.   11    line 1111 emulator     trapped
  2818.   32    trap #0 to #15         trapped
  2819.  
  2820.     The exact causes of the above exceptions (and how best to recover
  2821. from  them)  are  detailed at the end of  this  section,  but  to
  2822. summarise:
  2823.  
  2824. Exceptions  2  to  8 are caused by a  programmer  error  and  are
  2825. trapped by MonAM. Exception  9  can remotely be caused by programmer
  2826. error  and  is used by MonAM for single stepping. The  rest  (i.e.
  2827. Trap instructions) are  diverted  into MonAm,  but  can  subsequently
  2828. be re-defined to be  exploited  by programs if required.
  2829.       Occasionally  very  nasty crashes can cause the whole  screen
  2830. to fill with colourful garbage, which looks very  impressive,  but
  2831. is not very useful!
  2832.  
  2833. INVOKING MONAM
  2834.      Monam is invoked by typing the command
  2835.  
  2836. monam2 (RETURN)
  2837.  
  2838.      This can optionally be followed by a program name, and a command
  2839. line to be passed to it. For example:
  2840.  
  2841. monam2 c:genam2 examples/demo.s (RETURN)
  2842.  
  2843. will cause Monam to be invoked, to in turn load genam, and pass a
  2844. filename to it.
  2845.      When Monam has loaded, the screen will display three windows in
  2846. which all Monam information is displayed. Immidiatly after loading the
  2847. prompt enter program name or press return: will appear. At this point
  2848. you have to choose weather you are going to debug a particular
  2849. program, or just have a look around memory.
  2850.  
  2851. DEBUGGING A PROGRAM
  2852.      If you wish to debug a specific program, you should enter it's
  2853. filename including drive and directory if required and Manam will try
  2854. and load the program. If it fails, it will display:
  2855.  
  2856. AmigaDOS error xxx
  2857.  
  2858. and you can use the (CTRL)-L command to try again.
  2859.      Assuming the filename is valid, monam will load it. it will also
  2860. check for any symbols within a file. After a succesful load, the
  2861. prompt enter command line: will appear and you may type in a command
  2862. line thet will be passed to the program being debugged in the standard
  2863. way. If you don't want a command line, press return alone. The message
  2864.  
  2865. Exception:Breakpoint
  2866.  
  2867. will appear together with the front panel display. It says Breakpoint
  2868. because Monam places a breakpoint at the first instruction of the
  2869. program then executes it.
  2870.  
  2871. MONAM & MULTI-TASKING
  2872.      the Amiga is a multi-tasking machine, and this imposes some
  2873. restrictions on what monam can do. Having loaded a program (or task)
  2874. into it, that task is suspended. This means it is waiting, in this
  2875. case for a Monam command to let it continue. The other state the task
  2876. can be in is executing - that is it is running at the same time. Some
  2877. commands require one of these states to operate - for example you can
  2878. only single-step a task that is suspended. if it is running you will
  2879. get the error 'Task must be suspended!' when you try.
  2880.  
  2881. EXAMINING MEMORY
  2882.     If you are just interested in looking at memory, press (RETURN)
  2883. and you will see the front panel display, and get the command:
  2884.  
  2885. prompt.
  2886.  
  2887. SYMBOLIC DEBUGGING
  2888.      A major feature of MonAm is its ability to use symbols taken from
  2889. the original program whilst debugging. MonAm uses standard AmigaDOS
  2890. file SYMBOL hunks as produced by most Amiga programs that produce
  2891. executable files, such as linkers, compilers and GenAm.
  2892.  
  2893. MONAM DIALOGUE AND ALERT BOXES
  2894.      MonAm makes extensive use of dialogue and alert-boxes which
  2895. are similar in concept to those in intuition programs but have several
  2896. differances.
  2897.      A Monam dialogue box displays the prompt ESC to abort above  the
  2898. top  left  corner of the box together  with  a  prompt,  normally
  2899. followed  by a blank line with a cursor.  At any time a  dialogue
  2900. box  may be aborted by pressing Esc,  or data may be  entered  by
  2901. typing.  The cursor keys,  Backspace and Del keys may be used  to
  2902. edit  entered  text in the usual way and the whole  line  may  be
  2903. delted by pressing the (AMIGA)-X key combination.
  2904.      An entered line is terminated by pressing  the  Return
  2905. key, though if the line contains errors the screen will flash and
  2906. the  Return key will be ignored allowing correction of  the  data
  2907. before pressing Return again.
  2908.      A MonAM alert box is a small box displaying a  message  together
  2909. with the prompt (Return) and is normally used to inform the  user
  2910. of  some form of error.  The box will disappear on  pressing  the
  2911. Return or Esc keys, whichever is more convenient.
  2912.  
  2913. INITIAL DISPLAY
  2914.      Unless  you  have chosen the Debug option within the  editor  you
  2915. will be presented with a dialogue box prompting for an executable
  2916. program name. If you wish to debug a program from disk you should
  2917. enter the filename (which defaults to an extension of .PRG)  then
  2918. press Return,  then you will be prompted for any command line. If
  2919. you do not wish to debug a program from disk at this  stage,  for
  2920. example  you  wish to investigate memory,  press the Esc  key  or
  2921. enter a blank filename.
  2922.  
  2923. FRONT PANEL DISPLAY
  2924.      The main display of MonAm is via a Front Panel showing registers,
  2925. memory and instructions. The name Front Panel stems from the type
  2926. of  panels that were mounted on mainframe and mini  computers  to
  2927. provide  information on the state of the machine at a  particular
  2928. moment,  usually through the use of flashing lights. These lights
  2929. represent  whether  or  not  particular  flip-flops   (electronic
  2930. switches) within the computer are open or closed;  the flip-flops
  2931. that are chosen to be shown on this panel are normally those that
  2932. make  up  the internal registers and flags of the  computer  thus
  2933. enabling  programmers and engineers to observe what the  computer
  2934. is doing when running a program.
  2935.      So these are hardware front panel displays; what MonAM provides
  2936. you with is a software front panel - the code within MonAm works
  2937. out the state of your computer and then displays this information
  2938. on the screen.
  2939.  
  2940. The initial MonAm display consists of three windows:
  2941.  
  2942.      The top window (number 1) displays the values of the data and
  2943. address registers, together with the memory pointed to by these
  2944. registers.
  2945.      The next  window  (number 2)  is the  disassembly  window  which
  2946. displays several lines of instructions,  by default based  around
  2947. the program counter (PC),  shown in the title area of the window.
  2948. A => sign is used to denote the currant value of the PC
  2949.      Window number 3 is the memory window which displays a section  of
  2950. memory in word-aligned hex and ASCII.
  2951.      One  of  the most powerful features of MonAm is  its  flexibility
  2952. with  windows - up to 2 additional windows may  be  created,  the
  2953. font  size  can  be  changed,  and  windows  may  be  locked  to
  2954. particular registers, these features are detailed later.
  2955.  
  2956. SIMPLE WINDOW HANDLING
  2957.      MonAm has the concept of a current window - this is  denoted  by
  2958. displaying its title in black.  The current window may be changed
  2959. by pressing the Tab key to cycle between them, or by pressing the
  2960. (AMIGA) key together  with the window  number, for example (AMIGA)-2
  2961. selects  the disassembly window.
  2962.      NOTE: If your typing seems to be ignored in MonAm don't be
  2963. alarmed, it means that another window is active, such as your
  2964. programs. To correct this clich on any part of the MonAm display. you
  2965. can always tell when the monAm window is active because the mouse
  2966. pointer will be bug shaped.
  2967.  
  2968. COMMAND INPUT
  2969.      MonAm is controlled by single-key commands which creates a  very
  2970. fast user-interface,  though this can take getting used to if you
  2971. are  familiar with a line-oriented command interface  of  another
  2972. debugger. Users of HiSoft Devpac on other machines will find many
  2973. commands  are  identical,  particulary with the Spectrum  and  QL
  2974. debuggers, though the window commands are unique to MonAm. The
  2975. commands are almost identical to DEVPAC ST version 2.
  2976.      In general the (AMIGA) key - when  used  in conjunction with
  2977. other keys it it acts on the  current window.
  2978.      Commands  may  be entered in either upper or  lower  case.  Those
  2979. commands  whose  effects are potentially disastrous  require  the
  2980. Ctrl  key to be pressed in addition to a command  key.  The  keys
  2981. used  where  chosen to be easy to  remember,  wherever  possible.
  2982. Commands  take  effect immediately - there is no  need  to  press
  2983. Return  and  invalid commands are simply  ignored.  The  relevant
  2984. sections  of  the  front panel display  are  updated  after  each
  2985. command so any effects can be seen immediately.
  2986.      MonAm is a powerful and sometimes complex program and we  realise
  2987. that  it  is  unlikely  that many users  will  use  every  single
  2988. command.  For  this reason the remainder of the MonST  manual  is
  2989. divided into two sections - the former is an introduction to  the
  2990. basic  commands  of  the program,  while the  latter  is  a  full
  2991. reference section.  It is possible for new users and beginners to
  2992. use the debugger effectively while having only read the Overview;
  2993. don't be intimidated by the Reference section.
  2994.  
  2995. MONAM OVERVIEW
  2996.      To start with you will need to load a program to debug;  if  you
  2997. have  assembled a program to memory you can use the Debug  option
  2998. of the assembler or linker.
  2999.      The  most  common  command  in  MonAm is  probably  single-step,
  3000. obtained  by  pressing  Ctrl-Z (or Ctrl-Y if  you  find  it  more
  3001. convenient). This will execute the instruction at the PC, the one
  3002. shown in the Register window and,  normally,  also in the  Disas
  3003. sembly  window.  After executing it the debugger re-displays  the
  3004. values  of the registers and memory displayed,  so you can  watch
  3005. the processor execute your program, step by step. Single-stepping
  3006. is  the  best  way of going through sections  of  code  that  are
  3007. suspect  and  require deeper investigation,  but it is  also  the
  3008. slowest  - you may only be interested in a section of  code  near
  3009. the  end of your program which could take ages to get to  if  you
  3010. have to single-step all the way. There is, of course, an answer.
  3011.      A breakpoint is a special word placed into your program to  stop
  3012. it  running and enter MonST.  There are many types of  breakpoint
  3013. but  we  will  restrict ourselves to  the  simplest  for  now.  A
  3014. breakpoint  may  be  set by pressing (AMIGA)-B,  then  entering  the
  3015. address you wish to place the breakpoint. You can enter addresses
  3016. in MonSt in hex (the default base),  as a symbol, or as a complex
  3017. expression.  Examples of a valid address are  1A2B0,  prog_start,
  3018. 10+mydata.  If  you  type in an invalid address the  screen  will
  3019. flash and allow you to correct the expression.
  3020.      Having set a breakpoint you need some way of letting your program
  3021. actually  run,  and  Ctrl-R will do this.  If will  execute  your
  3022. program  using the registers displayed and starting from the  PC.
  3023. MonST will be re-entered if a breakpoint has been hit,  or if  an
  3024. exception occurs.
  3025.      MonAm uses its own screen display which is independent from  your
  3026. own  programs.  If you press the v key you will see your  current
  3027. programs  display,  pressing  another key switches  you  back  to
  3028. MonST. This allows you to debug programs without disturbing their
  3029. output at all.
  3030.      MonAm uses its own windows to,  and any window may be zoomed  to
  3031. the  full screen size by pressing (AMIGA)-Z.  To return to  the  main
  3032. display press (AMIGA)-Z or the Esc key.  The Esc key is also the best
  3033. way of getting out of anything you may have invoked by  accident.
  3034. The Zoom command,  like all (AMIGA)- commands,  works on the  current
  3035. window  which you can change by pressing Tab.  You can  dump  the
  3036. current window to your printer by pressing (AMIGA)-P.
  3037.      To change the address from which a window  displays  its  data,
  3038. press (AMIGA)-A,   then  enter  the  new  address.   Note  that  the
  3039. disassembly  window will always re-display from the PC after  you
  3040. single-step,  because  it  is locked to the PC.  The  locking  of
  3041. windows is detailed in the Reference section.
  3042.      To quit MonAm press Ctrl-C. This returns Monam directly to the
  3043. CLI. If the task you are debugging is still running or suspended when
  3044. you try and quit, you will be warned. If Monam terminates while the
  3045. task under investigationis running, the machine will crash if any
  3046. execption occurs subsiquently. A safer way is to use the ctrl-Q
  3047. command to stop the task first. If you used the Debug option from the
  3048. editor then  Ctrl-C will always terminate MonAm as well as your
  3049. program.
  3050.       We  hope this overview has given you a good idea  of  the  most
  3051. common  features  of  MonST to let you get on  with  the  complex
  3052. process of writing and debugging assembly language programs. When
  3053. you  feel  more confident you should try and read  the  Reference
  3054. section, probably best taken, like all medicine, in small doses.
  3055.  
  3056. MONAM REFERENCE
  3057.  
  3058. NUMERIC EXPRESSIONS
  3059.      MonAm has a full expression evaluator,  based on that in  GenST,
  3060. including operator precedence.  The main differences are that the
  3061. default  base  is hexadecimal (decimal may be denoted  with  a  \
  3062. sign),  there is no concept of types of expressions (relative  or
  3063. absolute), ø  is used only for multiplication and there is a not-
  3064. equals operator, <>.
  3065.      Symbols may be referred to and are normally  case-sensitive  and
  3066. significant  to either 8 or 22 characters (depending on the  form
  3067. of debug used), though this can be changed with the MonAm Preferences
  3068. command.
  3069.      Registers  may be referred to simply by name, such as A3 or D7
  3070. (case insensitive),  but this clashes with hex numbers. To obtain
  3071. such  hex numbers precede them with either a leading zero or a  $
  3072. sign. A7 refers to the user stack pointer.
  3073.      There  are several reserved symbols which are  case  insensitive,
  3074. namely CODE, SP, SR, and SSP. SP refers to either  the user- or
  3075. supervisor-stack, depending on the current value of the status
  3076. register. CODE refers to the first in the program. This is the same as
  3077. HUNK1. The second hunk is HUNK2 and so on.
  3078.      In addition there are 10 memories numbered M0 through  M9,  which
  3079. are treated in a similar way to registers and can be assigned  to
  3080. using  the Register Set command.  Memories 2 through 5  inclusive
  3081. refer  to  the current start address of the relevant  window  and
  3082. assigning to them will change the start address of that window.
  3083.      The MonAm expression evaluator also supports  indirection  using
  3084. the { and } symbols.  Indirection may be performed on a byte word
  3085. or long basis, by following the } with a period then the required
  3086. size,  which defaults to long.  If the pointer is invalid, either
  3087. because the memory is unreadable or even (if the word or longword
  3088. indirection is used) then the expression will not be valid.
  3089.  
  3090. For example, the expression:
  3091.  
  3092.        (data_start+10).w
  3093.  
  3094. will return the word contents of location data_start+10, assuming
  3095. data_start is even. Indirection may be nested in a similar way to
  3096. ordinary parenthesis.
  3097.  
  3098. WINDOW TYPES
  3099.      There  are  four  window types and the exact  contents  of  these
  3100. windows and how they are displayed is detailed below. The allowed
  3101. types of windows is shown in the table below.
  3102.  
  3103. Window  Allowed Types
  3104.   1     Register
  3105.   2     Disassembly
  3106.   3     Memory
  3107.   4     Disassembly, Memory or Source-code
  3108.   5     Memory
  3109.  
  3110. REGISTER WINDOW DISPLAY
  3111.      The  data  registers are shown in hex,  together with  the  ASCII
  3112. display  of  their low byte and then a hex display of  the  eight
  3113. bytes  they point to in memory.  The address registers  are  also
  3114. shown in hex,  together with a hex display of 12 bytes.  As  with
  3115. all hex displays in MonAm this is word-aligned, with non-readable
  3116. memory displayed as **.
  3117.      The status  register  is  shown  in  hex  and  in  flag   form,
  3118. additionally with U or S denoting user- or supervisor-modes.  A7'
  3119. denotes the supervisor stack pointer,  displayed in a similar way
  3120. to the other address registers.
  3121.      The PC value is shown together with a disassembly of the  current
  3122. instruction.  Where this involves one or more effective addresses
  3123. these are shown in hex, together with a suitably-sized display of
  3124. the memory they point to.
  3125.  
  3126. For example, the display
  3127.  
  3128.    TST.W $12A(A3)  ;00001FAE 0F01
  3129.  
  3130. signifies that the value of $12A plus register A3 is  $1FAE,  and
  3131. that the word memory pointed to by this is $0F01.  A more complex
  3132. example is the display
  3133.  
  3134.         MOVE.W $12A(A3),-(SP) ;00001FAE 0F01 =>002AC08 FFFF
  3135.  
  3136.      The source  addressing  mode is as before  but  the  destination
  3137. address  is $2AC08,  presently containing $FFFF.  Note that  this
  3138. display is always of a suitable size (MOVEM data being  displayed
  3139. as a quad-word) and when pre-decrement addressing is used this is
  3140. included in the address calculations.
  3141.  
  3142. DISASSEMBLY WINDOW DISPLAY
  3143.      Disassembly  windows display memory as disassembled  instructions
  3144. to the standard described below.  On the left the hex address  is
  3145. shown,  followed by any symbol,  then the disassembly itself. The
  3146. current value of the PC is denoted with >.
  3147.      If the instruction has a breakpoint placed on it this  is  shown
  3148. using  square brackets ([ ]) afterwards,  the contents  of  which
  3149. depend on the type of breakpoint.  For stop breakpoints this will
  3150. be the number of times left for this instruction to execute,  for
  3151. conditional  breakpoints  this  will  be  a  ?  followed  by  the
  3152. beginning  of the conditional expression,  for count  breakpoints
  3153. this  will  be a = sign followed by the current  count,  and  for
  3154. permanent breakpoints a symbol resembling a small zero in
  3155. superscript is shown.
  3156.      The exact format  of  the  disassembled  op-codes  is  Motorola
  3157. standard,  as  GenAM accepts.  All output is  upper-case  (except
  3158. lower-case  labels) and all numeric output is  hex,  except  Trap
  3159. numbers. Leading zeroes are suppressed and the $ hex delimiter is
  3160. not  shown on numbers less than 10.  Where relevant numerics  are
  3161. shown  signed.
  3162.      The only deviation from Motorola standard is  the
  3163. register  lists  shown in MOVEM instructions - in order  to  save
  3164. display  space  the  type of the second register in  a  range  is
  3165. abbreviated, for example:
  3166.  
  3167.         MOVEM.L d0-d3/a0-a2,-(sp)
  3168.  
  3169. will be disassembled as:
  3170.  
  3171.         MOVEM.L d0-3/a0-2,-(sp)
  3172.  
  3173.     Certain library calls will be shown symbolically even if no symbol
  3174. information was loaded with your program. The dissassembler is
  3175. intelligent and recognises a MOVE into register a6 follower by a JSR
  3176. using a6 and if it is recognised then will be displayed by name, for
  3177. example:
  3178.  
  3179.         MOVE.L   4,a6
  3180.         JSR      _LVOOpenLibrary(a6)
  3181.  
  3182.      It does this for the exec, graphics and intuition libraries,
  3183. using the special file libs:libfile.monam. if this file is not found
  3184. during Monams initialisation than such a dissassembly will not occur.
  3185.  
  3186. MEMORY WINDOW DISPLAY
  3187.      Memory  windows  display  memory in the form of  a  hex  address,
  3188. word-aligned hex display and ASCII.  Unreadable memory  locations
  3189. are denoted by **.  The number  of  bytes shown is calculated  from
  3190. the window width, up to a maximum of 16 bytes per line.
  3191.  
  3192. SOURCE-CODE WINDOW DISPLAY
  3193.      The source code window displays ASCII files in a similar way to a
  3194. screen  editor.  The default tab setting is 8 though this can  be
  3195. toggled to 4 with the Edit Window command.
  3196.  
  3197. WINDOW COMMANDS
  3198.     The (AMIGA) key is generally used for controlling windows,  and
  3199. when used to apply to the current window. This is denoted by having an
  3200. inverse title and can be changed by pressing the Tab or (AMIGA) plus
  3201. the window number.
  3202.      Most window commands work in any window,  zoomed or  not,  though
  3203. when  it  does  not make sense to do  something  the  command  is
  3204. ignored.
  3205.  
  3206. (AMIGA)-A                                             SET ADDRESS
  3207. This sets the starting address of a memory or disassembly window.
  3208.  
  3209. (AMIGA)-B                                          SET BREAKPOINT
  3210. Allows  the setting of any type of  breakpoint,  described  later.
  3211.  
  3212. (AMIGA)-E                                             EDIT WINDOW
  3213. On a memory window this lets you edit memory in hex or ASCII. Hex
  3214. editing can be accomplished using keys 1-9,  A-F,  together  with
  3215. the cursor keys. Pressing Tab switches between hex & ASCII, ASCII
  3216. editing takes each keypress and writes it to memory.  The  cursor
  3217. keys can be used to move about memory.  To leave edit mode  press
  3218. the Esc key.
  3219.  
  3220. On a register window this is the same as (AMIGA)-R, Register Set,
  3221. described shortly.
  3222.  
  3223. On a source code window this toggles the tab setting  between  4
  3224. and 8.
  3225.  
  3226. (AMIGA)-L                                            LOCK WINDOWS
  3227. This  allows disassembly and register windows to be locked  to  a
  3228. particular register. After any exception the start address of the
  3229. window is re-calculated, depending on the locked register.
  3230.      To  unlock simply enter a blank string. By default window 2 is
  3231. locked  to  the  PC.  You  can lock  windows  to  each  other  by
  3232. specifying a lock to a memory window, such as M2.
  3233.  
  3234. (AMIGA)-O                                              SHOW OTHER
  3235. This  prompts for an expression and displays it in  hex,  decimal
  3236. and as a symbol if relevant.
  3237.  
  3238. (AMIGA)-P                                            PRINTER DUMP
  3239. Dumps the current window onto the printer.  It can be aborted  by
  3240. pressing Esc.
  3241.  
  3242. (AMIGA)-R                                            REGISTER SET
  3243. Allows  any  register to be set to a  value,  by  specifying  the
  3244. register, an equals sign, then its new value. It can also be used
  3245. to set the value of memories. For example the line:
  3246.  
  3247.            a3=a2+4
  3248.  
  3249. sets  register A3 to be A2 plus 4.  You can also use this to  set
  3250. the  start address of windows when in zoom mode so that  on  exit
  3251. from  zoom  mode  the  relevant window  starts  at  the  required
  3252. address.
  3253.  
  3254. NOTE: Do not assign M4 if window 4 is currently  a  source-code
  3255. window.
  3256.  
  3257. (AMIGA)-S                                           SPLIT WINDOWS
  3258. This  either splits windows 2 into 2 and 4,  or splits  window  3
  3259. into  3 and 5.  Each new window is independent from its  creator.
  3260. Pressing (AMIGA)-S again will unsplit the window.
  3261.  
  3262. (AMIGA)-T                                             CHANGE TYPE
  3263. This only works on window 4 (created either by splitting window 2
  3264. or by loading a source file).  It changes the type of the  window
  3265. between disassembly,  memory and source-code (if a file has  been
  3266. loaded).
  3267.  
  3268. (AMIGA)-Z                                             ZOOM WINDOW
  3269. This zooms the current window to be full size. Other Alt commands
  3270. are  still available and normal size can be achieved by  pressing
  3271. Esc or (AMIGA)-Z again.
  3272.  
  3273. NOTE: Zooming the register windows shows the values of the memoris M0
  3274. to M9.
  3275.  
  3276. CURSOR KEYS
  3277.      The cursor keys can be used on the current window,  the action of
  3278. which depends on the window type.
  3279.  
  3280. On  a  memory  window all four cursor  keys  change  the  current
  3281. address, and Shift Up Cursor and Shift Down Cursor move a page in
  3282. either direction.
  3283.  
  3284. On  a  disassembly window Up Cursor and Down  Cursor  change  the
  3285. start  address  on an instruction basis,  Left Cursor  and  Right
  3286. Cursor change the address on a word basis.
  3287.  
  3288. On  a  source-code window Up Cursor and Down  Cursor  change  the
  3289. display on a line basis and Shift Up Cursor and Shift Down Cursor
  3290. on a page basis.
  3291.  
  3292. SCREEN SWITCHING
  3293.      Monam uses  its  own  screen  display and will always make itself
  3294. the front and active window whenever an exception (including
  3295. breakpoints) occurs.
  3296.  
  3297. V                                               VIEW OTHER SCREEN
  3298. This will put the monam screen to the back, normally showing your
  3299. prograns screen Pressing any key will return the MonAm screen (so lang
  3300. as you have not activated any other window).
  3301.  
  3302. BREAKPOINTS
  3303.      Breakpoints  allow you to stop the execution of your  program  at
  3304. specified points within it. MonST allows up to eight simultaneous
  3305. breakpoints,  each  of  which may be one of five  types.  When  a
  3306. breakpoint  is hit Monam is entered and then decides  whether  or
  3307. not to halt execution of your program,  entering the front  panel
  3308. display,  or continue,  this decision is based on the type of the
  3309. breakpoint and the state of your program's variables.
  3310.  
  3311. SIMPLE BREAKPOINTS
  3312.      These are one-off breakpoints which,  when executed,  are cleared
  3313. and cause Monam to be entered.
  3314.  
  3315. STOP BREAKPOINTS
  3316.      These are breakpoints that cause program execution to stop  after
  3317. a particular instruction has been executed a particular number of
  3318. times.  In  fact a simple breakpoint is really a stop  breakpoint
  3319. with a count of one.
  3320.  
  3321. COUNT BREAKPOINTS
  3322.      Merely counters; each time such a breakpoint is reached a counter
  3323. associated with it is incremented, and the program will resume.
  3324.  
  3325. PERMANENT BREAKPOINTS
  3326.      These  are  similar to simple breakpoints except  that  they  are
  3327. never  cleared  -  every  time  execution  reaches  a   permanent
  3328. breakpoint MonAm will be entered.
  3329.  
  3330. CONDITIONAL BREAKPOINTS
  3331.       The most powerful type of breakpoint and  these  allow  program
  3332. execution to stop at a particular address, only if an arbitrarily
  3333. complex set of conditions apply.  Each conditional breakpoint has
  3334. associated with it an expression (conforming to the rules already
  3335. described).  Every time the breakpoint is reached this expression
  3336. is evaluated,  and if it is non-zero (i.e. true) then the program
  3337. will be stopped, otherwise it will resume.
  3338.  
  3339. (AMIGA)-B                                          SET BREAKPOINT
  3340. This  is  a window command allowing the setting  or  clearing  of
  3341. breakpoints  at any time.  The line entered should be one of  the
  3342. following forms, depending on the type of breakpoint required:
  3343.  
  3344. <address>
  3345. will set a simple breakpoint.
  3346.  
  3347. <address>,<expression>
  3348. will  set a stop breakpoint at the given address,  after  it  has
  3349. executed <expression> times.
  3350.  
  3351. <address>,=
  3352. will set a count breakpoint.  The initial value of the count will
  3353. be zero.
  3354.  
  3355. <address>,*
  3356. will set a permanent breakpoint.
  3357.  
  3358. <address>,?<Expression>
  3359. will set a conditional breakpoint, using the given expression.
  3360.  
  3361. <address>,-
  3362. will clear any breakpoint at the given address.
  3363.  
  3364.      Breakpoints  cannot  be  set  on  addresses  which  are  odd   or
  3365. unreadable,  or  in  ROM.
  3366.      Every  time a breakpoint is reached,  regardless of  whether  the
  3367. program  is  interrupted  or  resumed,   the  program  state   is
  3368. remembered in the History buffer, described later.
  3369.  
  3370. HELP                                    SHOW HELP AND BREAKPOINTS
  3371. This displays the current breakpoints, task status, its segment list
  3372. (showing where the program is), free memory and the system memory
  3373. list. (AMIGA) commands are available within this display. For UK A500
  3374. 1.2 users (who cannot use the help key) this can also be obtained by
  3375. pressing (AMIGA)-H
  3376.  
  3377. Ctrl-B                                             SET BREAKPOINT
  3378. Included  mainly  for compatibility with MonAm 1,  this  sets  a
  3379. simple breakpoint at the start address of the current window,  so
  3380. long  as it is a disassembly window.  If a breakpoint is  already
  3381. there then it will be cleared.
  3382.  
  3383. U                                                        GO UNTIL
  3384. This prompts for an address, at which a simple breakpoint will be
  3385. placed then program execution resumed.
  3386.  
  3387. Ctrl-K                                           KILL BREAKPOINTS
  3388. This clears all set breakpoints.
  3389.  
  3390. Ctrl-A                                SET BREAKPOINT THEN EXECUTE
  3391. A  command  that places a simple breakpoint  at  the  instruction
  3392. after that at the PC and resumes execution from the PC.  This  is
  3393. particularly  for DBF-type loops if you don't want to go  through
  3394. the loop, but just want to see the result after the loop is over.
  3395.  
  3396. Ctrl-X                                     STOP PROGRAM EXECUTING
  3397. This is a command to stop your task while it is executing. It does
  3398. this by forcing the trace bit to be set, so you will get a trace
  3399. exception. While this does work, be very careful if you stop it in th
  3400. middle of some AmigaDOS ROM routines, particually signal handling and
  3401. message passing.
  3402.      NOTE: The above command accesses memory fields that are not
  3403. guarenteed to remain the same for differant versions of the Amiga
  3404. operating system. Initially you should try it at a time when nothing
  3405. important is in the machine to check compatibility with the version of
  3406. the operating system you are using before you are forced to use it
  3407. when a task goes a little beserk. This command used to be Ctrl-S on
  3408. MonAm version 1.
  3409.  
  3410. HISTORY
  3411.      MonAm  has  a  history  buffer in which  the  machine  status  is
  3412. remembered for later investigation.
  3413.      The most common way of entering data into the history buffer  is
  3414. when  you single-step,  but in addition every breakpoint  reached
  3415. and  every  exception caused enters the machine  state  into  the
  3416. buffer. Various forms of the Run command also cause entries to be
  3417. made into this buffer.
  3418.      NOTE:  The  history  buffer has room for five entries -  when  it
  3419. fills  the  oldest entry is removed to make room for  the  newest
  3420. entry.
  3421.  
  3422. H                                             SHOW HISTORY BUFFER
  3423. This opens a large window displaying the contents of the  history
  3424. buffer. All register values are shown including the PC as well as
  3425. a disassembly of the next instruction to be executed.
  3426.      NOTE: If a  disassembly  in the  History  display  includes  an
  3427. instruction  which has a breakpoint placed on the [ ]s will  show
  3428. the  current values for that breakpoint,  not the values  at  the
  3429. time of the entry into the history buffer.
  3430.  
  3431. QUITTING MONAM
  3432.  
  3433. Ctrl-C                                                  TERMINATE
  3434. This returns Monam directly to the CLi or to the editor if you invoked
  3435. Monam from the editor. If the task you are debuggingis still running
  3436. or suspended when you try and quit, you will be warned. If monam
  3437. terminates while the task under investigation is running, the machine
  3438. will crash if any exception occurs subsiquently. A safer way is to use
  3439. the Ctrl-Q command to stop the task first.
  3440.      If the Debug option has been used from the  GenAm editor  then
  3441. MonAm will  terminate  automatically  when  the  program  it  is
  3442. debugging has terminated.
  3443.  
  3444. CTRL-Q                                             QUIT A PROGRAM
  3445. This is a way of forcing a task being debugged to Quit. This can be
  3446. hazardous to use, and should only be done as a last resort. if your
  3447. program is terminated in this way it will not clean up, and thus not
  3448. de-allocate any memory it was using or close windows etc.
  3449.  
  3450.      NOTE: The above command accesses memory fields that are not
  3451. guaranteed to remain the same for differant versions of the operating
  3452. system. Initially you should try it at a time when nothing important
  3453. is in th machine to check compatability with the version of the
  3454. operating system you are using before you are forced to use it when a
  3455. task goes a little beserk.
  3456.  
  3457. LOADING & SAVING
  3458.  
  3459. Ctrl-L                                    LOAD EXECUTABLE PROGRAM
  3460. This  will prompt for an executable filename then a command  line
  3461. and will attempt to load the file ready for execution.  If  MonAm
  3462. has  already loaded a program it is not possible to load  another
  3463. until the former has terminated.
  3464.      The file to be loaded must be an executable file. use the load
  3465. binary file command if you wish to edit other file types.
  3466.      NOTE: This command in not available if Monam has been invoked
  3467. using Debug from the editor.
  3468.  
  3469. B                                                LOAD BINARY FILE
  3470. This  will  prompt  for  a filename  and  optional  load  address
  3471. (separated  by  a  comma)  and will  then  load  the  file  where
  3472. specified.  If  no  load  address is given then  memory  will  be
  3473. allocated  from  the system and used.  M0 will be set  to  the  start
  3474. address and M1 to the end address.
  3475.  
  3476. S                                                SAVE BINARY FILE
  3477. This  will  prompt  for  a  filename,  a  start  address  and  an
  3478. (inclusive) end address.  To re-save a file recently loaded  with
  3479. the above command <filename>,M0,M1 may be specified,  assuming of
  3480. course that M0 and M1 may be specified,  assuming of course  that
  3481. M0 and M1 have not been re-assigned.
  3482.  
  3483. A                                                 LOAD ASCII FILE
  3484. This  powerful command allows an ASCII file,  normally of  source
  3485. code,  to  be loaded and viewed within Monam,  Window 4  will  be
  3486. created if required then set up as a source code  window.  Memory
  3487. for  the  source  code is taken from the system so sufficient free
  3488. memory must be available.
  3489.  
  3490. EXECUTING PROGRAMS
  3491.  
  3492. Ctrl-R                                    RETURN TO PROGRAM / RUN
  3493. This  runs the current program with the given register values  at
  3494. full speed and is the normal way to resume execution after  entry
  3495. via a breakpoint.
  3496.  
  3497. Ctrl-Z                                                SINGLE-STEP
  3498. This  single-steps  the instruction at the PC  with  the  current
  3499. register values.  Single-stepping a Trap, Line-A or Line-F opcode
  3500. will, by default, be treated as a single instruction. This can be
  3501. changed using Preferences.
  3502.  
  3503. Ctrl-Y                                                SINGLE-STEP
  3504. Identical  to  Ctrl-Z above but included for the  convenience  of
  3505. German users.
  3506.  
  3507. Ctrl-T                           INTERPRET AN INSTRUCTION (TRACE)
  3508. This  interprets  the instruction at the PC using  the  displayed
  3509. register  values.  It is similar to Ctrl-Z but skips  over  BSRs,
  3510. JSRs, Traps, Line-A and Line-F calls, re-entering the debugger on
  3511. return from them to save stepping all the way through the routine
  3512. or trap it works on instructions in ROM or RAM.
  3513.  
  3514. Ctrl-S                                        SKIP AN INSTRUCTION
  3515. Ctrl-s increments the PC register by the size of the current
  3516. instruction thus causing it to be skipped. Use this instead of Ctrl-Z
  3517. when you know that this instruction is going to do something it
  3518. shouldn't.
  3519.  
  3520. R                                                   RUN (VARIOUS)
  3521. This is a general Run command and prompts for the type of the Run
  3522. to be done, selected by pressing a particular key.
  3523.  
  3524. Run    G  GO
  3525. This  is  identical to Ctrl-R,  and resumes the program  at  full
  3526. speed.
  3527.  
  3528. Run    I  Instruction
  3529. This executes the entered number of instructions remembering
  3530. information in the history buffer and then returning to monam.
  3531.  
  3532. Traps will be treated as single-instructions.
  3533.  
  3534. SEARCHING MEMORY
  3535.  
  3536. G                                  SEARCH MEMORY (GET A SEQUENCE)
  3537. This  will  prompt Search for  B/W/L/T/I?,  standing  for  Bytes,
  3538. Words, Longs, Text and Instructions.
  3539.      If  you select B, W or L you will then be prompted to enter  the
  3540. sequence  of numbers you wish to search for,  each  separated  by
  3541. commas.  MonST is not fussy about word-alignment when  searching,
  3542. so it can find longs on odd boundaries, for example.
  3543.      If you select T you may search for any given text  string,  which
  3544. you will be prompted for. The search will be case-dependent.
  3545.      If you select I you can search for part or all of the mnemonic of
  3546. an instruction,  for example if you searched for $14 (A you would
  3547. find  an  instruction like MOVE.L D2,$14(A0).  The  case  of  the
  3548. string you enter is important (unlike Monam version 1),  but  you
  3549. should  bear in mind the format the disassembler  produces,  e.g.
  3550. always use hex numbers, refer to A7 rather than SP and so on.
  3551.      Having  selected  the  search type  and  parameters,  the  search
  3552. begins, control passing to the Next command, described below.
  3553.  
  3554. N                                                       FIND NEXT
  3555.      This can be used after the G command to find subsequent
  3556. ccurences of the search data.  With the B,  W, L and T options you
  3557. will always find at least one occurrence,  which will be in the buffer
  3558. within MonAM that is used for storing the sequence.  With the  T
  3559. option you may also find a copy in the system keyboard  buffer.
  3560. With these options, the Esc key is tested every 64k bytes and can
  3561. be used to stop the search.  With the be used to stop the search.
  3562. With  the I option,  which is very much slower,  the Esc  key  is
  3563. tested every 2 bytes.
  3564.      The  search area of memory goes from 0 to the end of chip memory,
  3565. then from $F80000 to $FFFFFF (the ROM), then any additional RAM.
  3566.      The search will start just past the start address of the  current
  3567. window  (except register windows) and if an occurrence  is  found
  3568. re-display the window at the given address.
  3569.  
  3570. SEARCHING SOURCE-CODE WINDOWS
  3571.      If  the  G  command is used on a source-code window  the  T  sub-
  3572. command  is  automatically chosen and if the text  is  found  the
  3573. window will re-display the line containing it.
  3574.  
  3575. MISCELLANEOUS
  3576.  
  3577. Ctrl-P                                                PREFERENCES
  3578. This permits control over various options within MonAM. The first
  3579. three require Y/N answers,  pressing Esc aborts or Return  leaves
  3580. them alone.
  3581.  
  3582. RELATIVE OFFSETS
  3583.      This  option  defaults to On and effects the disassembly  of  the
  3584. address  register  indirect with offset  addressing  modes,  i.e.
  3585. xxx(An).  With  the  option  on the current value  of  the  given
  3586. address register is added to the offset then searched for in  the
  3587. symbol table.  If found it is disassembled as symbol  (An).  This
  3588. option  is  very useful for certain styles of  assembly  language
  3589. programming  as  well as high level languages which  use  a  base
  3590. register as a major offset, such as HiSoft BASIC which uses A3 as
  3591. a pointer to the run-time system.
  3592.  
  3593. SYMBOLS OPTION
  3594.      This  allows  control over the use of symbols in  expressions  in
  3595. MonAm.  It will firstly ask whether the case of symbols should be
  3596. ignored,  pressing Y will cause case independent searching to  be
  3597. used.  It  will  then prompt for the maximum length  of  symbols,
  3598. which is normally 32 but may be reduced to as low as 8. Or increased
  3599. if required.
  3600.  
  3601. PRINTER DEVICE
  3602.      This lets you set the device that Monam uses for its printer
  3603. commands, the default is PRT:
  3604.  
  3605. SAVE PREFERANCES
  3606.      Reply Y to this command to save your current preferances to the
  3607. file monam2.inf in the current directory. When monAm2 loads it will
  3608. read your current preferances from this file. Monam2.inf is firstly
  3609. searched for in the current directory, then in the c: directory, in a
  3610. similar way to the editor preferances file.
  3611.  
  3612. I                                                INTELLIGENT COPY
  3613. This  copies  a block of memory to another  area.  The  addresses
  3614. should be entered in the form:
  3615.  
  3616.         <start>,<inclusive end>,<destination>
  3617.  
  3618.      The copy is intelligent in that the block of memory may be copied
  3619. to a location which overlaps its previous location.
  3620.      NOTE:  No  checks at all are made on the validity  of  the  move;
  3621. copying to non-existent areas of memory is likely to crash Monam
  3622. and corrupting system areas may well crash the machine.
  3623.  
  3624. L                                                     LIST LABLES
  3625. This opens up a large window and displays all loaded symbols. Any
  3626. key displays the next page, pressing Esc aborts. The symbols will
  3627. be  displayed  in the order they were found on the  disk  (or  in
  3628. memory if using the Debug option from the editor).
  3629.  
  3630. Ctrl-U name                                        UNLOAD SYMBOLS
  3631. This command can only be used if you are debugging a task which had a
  3632. symbol table loaded with it. What it does is de-allocate the memory
  3633. used for storing symbols, freeing it for the system to use. This can
  3634. be very useful if memory is tight while debugging a lager program, as
  3635. you can load it, together with symbols, set a breakpoint at a symbolic
  3636. address, then lose the labels before letting it run. Of course once
  3637. you hit your breakpoint you won't have any symbols.
  3638.      NOTE: Thois command used to be Ctrl-L on Monam version 1.
  3639.  
  3640. COMMAND SUMMARY
  3641.  
  3642. WINDOW COMMANDS
  3643. (AMIGA)-A ..................... Set Address
  3644. (AMIGA)-B ..................... Set Breakpoint
  3645. (AMIGA)-E ..................... Edit Window
  3646. (AMIGA)-L ..................... Lock Window
  3647. (AMIGA)-O ..................... Show Other
  3648. (AMIGA)-P ..................... Printer Dump
  3649. (AMIGA)-R ..................... Register Set
  3650. (AMIGA)-S ..................... Split Windows
  3651. (AMIGA)-T ..................... Change Type
  3652. (AMIGA)-Z ..................... Zoom Window
  3653.  
  3654. BREAKPOINTS
  3655. (AMIGA)-B ..................... Set Breakpoint
  3656. Help ...................... Show Help and Breakpoints
  3657. Ctrl-B .................... Set Breakpoint
  3658. U ......................... Go Until
  3659. Ctrl-K .................... Kill Breakpoints
  3660. Ctrl-A .................... Set Breakpoint then Execute
  3661. Ctrl-X .................... Stop program executing
  3662.  
  3663. LOADING AND SAVING
  3664. Ctrl-L .................... Load Executable Program
  3665. B ......................... Load Binary File
  3666. S ......................... Save Binary File
  3667. A ......................... Load ASCII File
  3668.  
  3669. EXECUTING PROGRAMS
  3670. Ctrl-R .................... Return to program/Run
  3671. Ctrl-Z .................... Single-Step
  3672. Ctrl-Y .................... Single-Step
  3673. Ctrl-T .................... Interpret an Instruction (Trace)
  3674. Ctrl-S..................... Skip instruction
  3675. R ......................... Run (various)
  3676.  
  3677. SEARCHING MEMORY
  3678. G ......................... Search Memory (Get a sequence)
  3679. N ......................... Find Next
  3680.  
  3681. MISCELLANEOUS
  3682. Ctrl-C .................... Terminate
  3683. Ctrl-Q..................... Quit program
  3684. Ctrl-P .................... Preferences
  3685. I ......................... Intelligent Copy
  3686. W ......................... Fill Memory With
  3687. L ......................... List Labels
  3688. Ctrl-U..................... Unload symbols
  3689. P ......................... Disassemble to Printer/Disk
  3690. M ......................... Modify Address
  3691. O ......................... Show Other Bases
  3692. D ......................... Change Drive & Directory
  3693. H ......................... Show History Buffer
  3694. V.......................... View other screen
  3695.  
  3696. DEBUGGING STRATAGEM
  3697.  
  3698. RESTRICTIONS
  3699.      As it runs as a process MonAm relies on the exec.intuition and
  3700. graphics libraries. If your program starts destroying memory to which
  3701. it has no right it is possible for it to fatally corrupt something the
  3702. system needs so that when monam is entered after an exception the
  3703. machine will crash. Fortuanely this type of error is rare, usually
  3704. address errors occur before programs start destroying memory.
  3705.      When a program is invoked from Monam it is set up to look as if
  3706. it has been run from the CLI, not the workbench.
  3707.      Monam cannot single step or breakpoint any code when executing in
  3708. supervisor mode. This is because the exec exception handler checks for
  3709. an execption in supervisor mode, amd will put up a guru alert if this
  3710. is the case. If not it will enter Monam and work normally.
  3711.      If your program creates another program or task you cannot use
  3712. monam to breakpoint it or single-step. Monam can only debug the
  3713. program that was specified when it initially loaded.
  3714.      Don't try and run the standard system programs from within Monam,
  3715. such as dir. These rely on undocumented registers (particually a5) and
  3716. memory areas which monam cannot emulate.
  3717.      Due to a hardware feature, a word - or longword-access on odd
  3718. memory locations 1 to 7 inclusive will cause a complete machine crash.
  3719. There seems to be nothing we can do to prevent this.
  3720.  
  3721. BUG HUNTING
  3722.      There  are probably as many strategies for finding bugs as  there
  3723. are programmers;  there is really no substitute for learning  the
  3724. hard way,  by experience.  However, there are some hints which we
  3725. have learnt, the hard way!
  3726.      Firstly, a very good way of finding bugs is to look at the source
  3727. code  and  think.  The  disadvantage of reaching  first  for  the
  3728. debugger,  then second for the source code,  is that it gets  you
  3729. into  bad  habits.  You may switch to a  machine  or  programming
  3730. environment that does not offer low-level debugging,  or at least
  3731. not one as powerful as you are used to.
  3732.      If a program fails in a very detectable way,  such as causing  an
  3733. exception,  debugging is normally easier than if,  say, a program
  3734. sometimes doesn't quite work exactly as it should.
  3735.      Many  bugs  are  caused by a  particular  memory  location  being
  3736. stepped on.  Whether the offending memory location is detectable,
  3737. by producing a bus error,  for example,  a conditional breakpoint
  3738. placed  at  one or more main subroutines can  help  greatly.  For
  3739. example, suppose the global variable main_ptr is somehow becoming
  3740. odd during execution,  the conditional expression could be set up as:
  3741.  
  3742. (main_ptr)&1
  3743.  
  3744.      Count  breakpoints  are a good way of tracking down  bugs  before
  3745. they occur. For example, suppose a particular subroutine is known
  3746. to eventually fail but you cannot see why,  they you should set a
  3747. count breakpoint on it,  then let the program run.  At the  point
  3748. where the program stops, because of an exception say, look at the
  3749. value  of  the  count  breakpoint  (using  Help).  Terminate  the
  3750. program, re-load it, then set a stop breakpoint on the subroutine
  3751. for that particular value or one before it.  Let it run, then you
  3752. can  follow  through  the sub-routine on the very  call  that  it
  3753. fails on, to try and work out why.                      GOOD LUCK!
  3754.  
  3755. EXCEPTION ANALYSIS
  3756.      When an unexpected exception occurs,  it's very useful to be able
  3757. to work out where and why it occurred and,  possibly,  to  resume
  3758. execution.
  3759.  
  3760. BUS ERROR
  3761.      If the PC is in some non-existent area of memory then look at the
  3762. relevant stack to try and find a return address to give a clue as
  3763. to  the cause,  probably an unbalanced stack.  If the PC is in  a
  3764. correct  area of your program then the bus error must  have  been
  3765. caused  by a memory access to non-existent or  protected  memory.
  3766. Recovering  from bus errors and resuming execution  is  generally
  3767. not possible.
  3768.  
  3769. ADDRESS ERROR
  3770.      If  the PC is somewhere strange the method above should be  used,
  3771. otherwise the error must have been caused by a program access  to
  3772. an  odd  address.  Correcting a register value may be  enough  to
  3773. resume execution, at least temporarily.
  3774.  
  3775. ILLEGAL INSTRUCTION
  3776.      If the PC is in very low memory, below around $30, it is probable
  3777. that it was caused by a jump to location 0.  If you use MonAM to
  3778. look  here  you will normally see various ORI instructions  (really
  3779. longword   pointers)   and eventually an illegal instruction.
  3780.  
  3781. PRIVILEGE VIOLATION
  3782.      This  is  caused by executing a privileged  instruction  in  user
  3783. mode,  normally  meaning  your program has gone  horribly  wrong.
  3784. Bumping  the PC past the offending instruction is unlikely to  be
  3785. much help in resuming the program.
  3786.  
  3787. APPENDIX A: AmigaDOS error codes
  3788.      This appendix details the numeric AmegaDOS errors and their
  3789. meanings:
  3790.  
  3791. 103     insufficient free store                 out of memory
  3792. 104     task table full                         limit of 20 cli's
  3793. 120     argument line invalid or too long       when using CLI commands
  3794. 121     file is not an object module            trying to execute a non-
  3795.                                                 executable file
  3796. 122     invalid resident library during load
  3797. 202     object in use                           such as a file by another
  3798.                                                 program
  3799. 203     object already exists
  3800. 204     directory not found
  3801. 205     object not found                        most commonly a file
  3802. 206     invalid window                          in name specification
  3803. 209     packet request type unknown
  3804. 210     invalid stream component name           name too long or contains
  3805.                                                 control characters
  3806. 211     invalid object lock
  3807. 212     object not of required type             such as directory name
  3808.                                                 instead of file
  3809. 213     disk not validated                      disk is still being
  3810.                                                 validated, or is bad
  3811. 214     disk write-protected
  3812. 215     rename across devices attempted
  3813. 216     directory not empty                     when trying to delete it
  3814. 218     device not mounted                      after specifying a volume
  3815.                                                 name
  3816. 219     seek error
  3817. 220     comment too big                         file comments must be
  3818.                                                 less than 80
  3819. 221     disk full
  3820. 222     file is protected from deletion
  3821. 223     file is protected from writing
  3822. 224     file is protected from reading
  3823. 225     not a DOS disk
  3824. 226     no disk in drive
  3825. 232     no more enteries in directory
  3826.  
  3827. APPENDIX B: GenAM error messages
  3828.      Genam can produce a large number of error messages, most of which
  3829. are  pretty  self explanatory.  This appendix lists them  all  in
  3830. alphabetic  order,  with clarifications for those  which  require
  3831. them.
  3832.      Please note that GenAM is continually being improved and list may
  3833. not  agree  exactly  with the version  you  have,  there  may  be
  3834. additional messages not documented here.
  3835.  
  3836. ERRORS
  3837.      If you get a message beginning with INTERNAL please tell us - you
  3838. should never see these.
  3839.  
  3840. .W or .L expected as index size
  3841.  
  3842. absolute expression MUST evaluate
  3843.  
  3844. absolute not allowed
  3845.  
  3846. additional symbol on pass 2
  3847.             somehow a symbol has appeared during pass 2 that  did
  3848.             not appear during pass 1
  3849.  
  3850. address register expected
  3851.  
  3852. addressing mode not allowed
  3853.  
  3854. addressing mode not recognised
  3855.  
  3856. BSS or OFFSET cannot contain data
  3857.             OFFSET  sections  and non-GST BSS sections  can  only
  3858.             contain DS directives
  3859.  
  3860. cannot create a binary file
  3861.             could be a bad filename,  or a write-protected  disk,
  3862.             etc.
  3863.  
  3864. cannot export symbol
  3865.  
  3866. cannot import symbol
  3867.  
  3868. cannot reset MACRO definitions or define in REPTs
  3869.             macro definitions may not be nested or defined within
  3870.             repeat loops
  3871.  
  3872. cannot nest repeat loops
  3873.  
  3874. comma expected
  3875.  
  3876. data register expected
  3877.  
  3878. data too large
  3879.  
  3880. division by zero
  3881.  
  3882. duplicate MODULE name
  3883.  
  3884. module names must be unique
  3885.  
  3886. error during listing output
  3887.             listing will be stopped at this point
  3888.  
  3889. error during writing binary file
  3890.             normally disk full
  3891.  
  3892. executable code only
  3893.             only executable code may be assembled to memory
  3894.  
  3895. expression mismatch
  3896.             normally a syntax error within an expression
  3897.  
  3898. fatally bad conditional
  3899.             there were more ENDCs in a macro than IFs
  3900.  
  3901. file not found
  3902.  
  3903. forward reference
  3904.  
  3905. garbage following instruction
  3906.  
  3907. illegal BSR.S
  3908.             a BSR.S to the following instruction is not allowed -
  3909.             change it to BSR
  3910.  
  3911. illegal type combination
  3912.  
  3913. immediate data expected
  3914.  
  3915. imported label not allowed
  3916.  
  3917. include file read error
  3918.  
  3919. instruction not recognised
  3920.  
  3921. invalid FORMAT parameter
  3922.  
  3923. invalid INCDIR
  3924.             You have used more than 500 bytes of directory
  3925. specifications
  3926.  
  3927. invalid IF expression, ignored
  3928.  
  3929. invalid MOVEF addressing mode
  3930.  
  3931. invalid number
  3932.  
  3933. invalid numeric expression
  3934.             the  symbol  is not defined or relative or  a  syntax
  3935.             error
  3936.  
  3937. invalid option
  3938.  
  3939. invalid printer parameter
  3940.  
  3941. invalid register list
  3942.  
  3943. invalid section name, TEXT assumed
  3944.  
  3945. invalid size
  3946.  
  3947. line malformed
  3948.  
  3949. linker format restriction
  3950.             the AmigaDOS format is restrictive about where it  allows
  3951.             imports
  3952.  
  3953. local not allowed
  3954.  
  3955. missing close bracket
  3956.  
  3957. missing ENDC
  3958.             there were more IFs than ENDCs
  3959.  
  3960. missing quote
  3961.  
  3962. misuse of label
  3963.  
  3964. not yet implemented
  3965.  
  3966. number too large
  3967.  
  3968. odd address
  3969.  
  3970. option must be at start
  3971.  
  3972. ORG not allowed
  3973.  
  3974. out of memory
  3975.  
  3976. phasing error
  3977.             should  never happen,  look  investigate  immediately
  3978.             before first such error
  3979.  
  3980. program buffer full
  3981.             change  the  program buffer size when  assembling  to
  3982.             memory
  3983.  
  3984. register expected
  3985.  
  3986. relative not allowed
  3987.  
  3988. relocation not allowed
  3989.  
  3990. repeated include file
  3991.  
  3992. each include file may only be included once on each pass
  3993.  
  3994. source expired prematurely
  3995.             with an IF, MACRO or REPT and the source ran out
  3996.  
  3997. spurious ENDC
  3998.  
  3999. spurious ENDM or MEXIT
  4000.  
  4001. spurious ENDR
  4002.  
  4003. symbol defined twice
  4004.  
  4005. symbol expected
  4006.  
  4007. undefined symbol
  4008.  
  4009. user error
  4010.             caused by FAIL directive
  4011.  
  4012. wrong processor
  4013.  
  4014. XREFs not allowed within brackets
  4015.  
  4016. WARNINGS
  4017. 68010 instruction, converted to MOVE SR
  4018.             MOVE CCR, is not a 68000 instruction
  4019.  
  4020. branch made short
  4021.             by optimising
  4022.  
  4023. directive ignored
  4024.  
  4025. invalid LINK displacement
  4026.             if negative or odd
  4027.  
  4028. offset removed
  4029.             xx(An) form reduce to (An) by optimising
  4030.  
  4031. relative cannot be relocated
  4032.  
  4033. short branch converted to NOP
  4034.  
  4035. sign extended operand
  4036.             data in MOVEQ needed sign extension to fit
  4037.  
  4038. size should be .W
  4039.  
  4040. APPENDIX C: CALLING THE OPERATING SYSTEM
  4041.  
  4042. INTRODUCTION
  4043.      The Amiga operating system is arguably with the exception of OS/2
  4044. the most sophisticated of any mass produced computer, and is also the
  4045. most complicated. The whole machine is based around the concept of
  4046. libraries, which are essentially groups of subroutones (or functions
  4047. to C-programmers) indexed off a large jump block. The appendix is
  4048. intended to explain the basics of calling libraries from assembly
  4049. language, and to give an idea of what each can be used for. One small
  4050. Appendix cannot possibly describe the whole operating system, it is
  4051. only meant as an introduction.
  4052.     Please note that was written with version 1.2 of Kickstart in
  4053. mind, it is possible subsiquent versions may differ slightly. Any
  4054. important differances should be detailed in the readme file.
  4055.  
  4056. LIBRARIES
  4057.      The most basic library is the exec library, which has to be
  4058. called to open nay other library, among other things. As with all
  4059. libraries, a library base pointer is required to access it, and this
  4060. must be loaded into register a6 before calling any function. The exec
  4061. library is unique as that it dosen't have to be opened to obtain a
  4062. base pointer - this can be obtained from the longword at location 4 -
  4063. the only location in the whole machine guaranteed to remain the same
  4064. in the future. The base pointer so obtained can then be used to open
  4065. further libraties, to obtain other library base pointers, and so on.
  4066. Note that most libraries require a6 to be contained in the base
  4067. pointer for correct operation (as they call the other routines in the
  4068. same library) though not all do. Parimiters are passed to library
  4069. routines in requesters, and sa a general rule requesters d0/d1/a0/a1
  4070. should be assumed to be corrupted by any call.
  4071.      A large number of include files are supplied with DEVPAC to allow
  4072. easy access to the various parts of the opearting system. These
  4073. include files containing macro definitions, library offset symbols,
  4074. data structure definitions, and bit field symbols. There now follows a
  4075. library table showing the names of the various components, and where
  4076. the definitions can be found in the include directory.
  4077.  
  4078. FILE: this shows the file that contains the macro definitions and _LVO
  4079. offsets for calling the library.
  4080.  
  4081. NAME MACRO: this normally consists of a dc.b statement defining the
  4082. ASCII for the name, ending in a null.
  4083.  
  4084. BASE POINTER: this is the symbolic name of the longword used for
  4085. storing the base pointer. It always starts with an underline
  4086. character, though when used from most C compilers this underline is
  4087. not shown.
  4088.  
  4089. CALLING MACRO: this is the name of the macro that calls a particular
  4090. library. Note that this will corrupt register a6 as it will be loaded
  4091. with the relevant library base pointer.
  4092.  
  4093. LIBRARY         FILE                            NAME MACRO
  4094.                         BASE POINTER                    CALLING MACRO
  4095. diskfont        libraries/diskfont_lib.i        DISKFONTNAME
  4096.                         _DiskfontBase                   CALLDISKFONT
  4097. dos             libraries/dos_lib.i             DOSNAME *
  4098.                         _DOSBase                        CALLDOS
  4099. exec            exec/exec_lib.i                 EXECNAME
  4100.                         _SysBase                        CALLEXEC
  4101. expansion       libraries/expansion_lib.i       EXPANSIONNAME **
  4102.                         _ExpansionBase                  CALLEXP
  4103. graphics        grapgics/graphics_lib.i         GRAFNAME
  4104.                         _GfxBase                        CALLGRAF
  4105. icon            workbench/icon_lib.i            ICONNAME
  4106.                         _IconBase                       CALLICON
  4107. intuition       intuition/intuition_lib.i       INTNAME
  4108.                         _IntuitionBase                  CALLINT
  4109. mathffp         math/mathffp_lib.i              FFPNAME
  4110.                         _MathBase                       CALLFFP
  4111. mathdouble      math/mathieeedoubas_lib.i       IEEEDOUBNAME
  4112.                         _MathIeeeDouBasBase             CALLIEEEDOUB
  4113. mathtrans       math/mathtrans_lib.i            MATHTRANSNAME
  4114.                         _MathTransBase                  CALLMATHTRANS
  4115. translator      libraries/translator_lib.i      TRANSNAME
  4116.                         _TranslatorBase                 CALLTRANS
  4117.  
  4118.      For example, to call the exec library function OpenLibrary
  4119. suitable assembler source code would be
  4120.  
  4121.         CALLEXEC    OpenLibrary
  4122.  
  4123. This macro is expanded into
  4124.  
  4125.         move.l      (_SysBase).w,a6
  4126.         jsr         _LVOOpenLibrary(a6)
  4127.  
  4128.  * = name macro definition can be found in file libraries/dos.i
  4129. ** = mane macro can be found in file libraries/expansion.i
  4130.  
  4131. DISKFONT LIBRARY:
  4132.      This is a library for handling fonts that are normally resident
  4133. on the disk.
  4134. FILES: libraries/diskfont.i and diskfont_lib.i
  4135.  
  4136. DOS LIBRARY:
  4137.      One of the most straightforward of the libraries to use, this
  4138. handles file i/o (input/output) to devices, including disk and
  4139. console. It has some slight anomalities, notabily addersses have to be
  4140. passed in data registers, and many pointers have to be BCPL-type (ie.
  4141. longword aligned and divided by 4)
  4142. FILES: libraries/dos.i  dos_lib.i and dosextens
  4143.  
  4144. EXEC LIBRARY:
  4145.      This is the lowest level of library, responsible for things like
  4146. memory management, library calls, and message passing. The library
  4147. never has to be opened - its base pointer is contained in location 4.
  4148. FILES: exec/ables.i  alerts.i  devices.i  errors.i  exec.i  execbase.i
  4149. execname.i  exec_lib.i  funcdef.i  initializers.i  interrupts.i  io.i
  4150. libraries.i  lists.i  memory.i  nodes.i  ports.i  resident.i
  4151. strings.i  tasks.i  and types.i
  4152.  
  4153. GRAPHICS LIBRARY:
  4154.      This is responsible for controlling exectly what appears on your
  4155. monitor, including things like drawing lines, printing text,
  4156. controlling RastPorts, sprite handling and fonts.
  4157. FILES: graphics/clip.i  copper.i  display.i  gels.i  gfx.i  gfxbase.i
  4158. graphics_lib.i  layers.i  rastport.i  regions.i  sprite.i  text.i  and
  4159. view.i
  4160.  
  4161. ICON LIBRARY:
  4162.      This library is responsible for handling the icons displayed by
  4163. the Workbench.
  4164. FILES: workbench/icon.i  icon_lib.i
  4165.  
  4166. INTUITION LIBRARY:
  4167.      This library is the lagest and is responsible for the windowing
  4168. intuition user interface. It has a very large number of functions,
  4169. including those for window conrtol, screens. gadgets, requesters, and
  4170. event handling.
  4171.      The main file is large and also includes a large number of other
  4172. files, so don't be surprised if it takes a little while to read it
  4173. all. It can be worthwile to create your own specilised version without
  4174. the less-often used constants, which can reduce the amount of other
  4175. include files required.
  4176. FILES: intuition/intuition.o  and intuition_lib.i
  4177.  
  4178. MATHS LIBRARIES:
  4179.      There are three maths libraries, all based on the official
  4180. Motorola routines. The FFP (Fast Floating Point) library uses an 8-bit
  4181. exponent, 24-bit mantissa format. The format used was designed for the
  4182. 68000 series, and is exclusive to Motorola. The IEEE double library
  4183. offers doublr-precision using IEEE standard formats for numbers, and
  4184. the Trancendental library is used for FFP trig and other functions.
  4185. FILES: math/mathffp_lib.i  mathieeedoubbas_lib.i  and  mathtrans_lib.i
  4186.      As a genaral rule you should use GenAm in case sensative mode
  4187. (the default) when using the supplied include files. note that every
  4188. include file always includes any others it needs automatically, so you
  4189. don't need to worry about it.
  4190.  
  4191. EXAMPLE PROGRAMS
  4192.     To help you get started programming AmigaDOS from assembly
  4193. language we have provided the source to a few example programs in the
  4194. examples directory.
  4195.  
  4196. DEMO.S
  4197.      this is the program used for the tutorial at the beginning of the
  4198. manual. It uses the DOS library to print a message on the current CLI
  4199. window.
  4200.  
  4201. FREEMEM.S
  4202.     This program that uses intuition to create a window in which the
  4203. system free memory is constantly displayed, until the close gadget is
  4204. clicked on. To run this concurrently from the CLI use the command:
  4205.  
  4206. run examples/freemem
  4207.  
  4208. HELLOWORLD.S
  4209.      This is the assembly language conversion of the C program 'final
  4210. version of the simple program' described at the beginning of
  4211. 'intuition - the amiga user interface'. The conversion has not been
  4212. optimised in any way, for example, the structure assignment for
  4213. NewScreen would be more efficient using dc.w/dc.l statements, but has
  4214. been left as MOVE instructions for a more accurate conversion. The
  4215. program opens up a custom screen and, within it, a simple message.
  4216.  
  4217. CLI vs WORKBENCH
  4218.      There are two program enviroments on the amiga - the windows &
  4219. icon driven workbench, and the CLI. Devpac itself runs only under the
  4220. latter, as do most example programs, the differance being in the
  4221. startup and exit code.
  4222.  
  4223. CLI STARTUP
  4224.      When a program is run from the CLI it starts with register a0
  4225. containing the address of the command linem and d0 containing its
  4226. length. The DOS handles returned by input and output can be used for
  4227. i/o with the console device, and to exit the program should simply
  4228. RTS.
  4229.  
  4230. WORKBENCH STARTUP
  4231.      When a program is run from the Workbench it has to wait firstly
  4232. for a message, and on terminating it has to reply to the message
  4233. (after doing a forbid call) before RTSing. The DOS functions input and
  4234. output will not return valid handles, so you need to open a window to
  4235. perform any console i/o
  4236.      the startup differances are detailed in part 4, chapter 2 of the
  4237. ROM Kernal Menual Volume 1, together with the assembly language source
  4238. of the startup code used by C programs. Note that there is a bug in it
  4239. - the routine openDOS should have a moveq #0,d0 instruction added
  4240. before the call to OpenLibrary, otherwise a fatal alert can be
  4241. produced.
  4242.      A skeleton version of this for assembly language programmers can
  4243. be found in the file misc/easystart.i which is included by the
  4244. freemem2.s example program. It should be included at the very front of
  4245. your programs, and handles the message-passing to allow programs to be
  4246. run from workbench. Of course to do this you will need to create an
  4247. icon for your program, using iconed.
  4248.  
  4249. APPENDIX D: USING THE CLI
  4250.      All this section is covered in the Amiga manuals you get with the
  4251. machine so look them up yourselves!
  4252.  
  4253. APPENDIX E: CONVERTING FROM OTHER ASSEMBLERS
  4254.      Most 68000 assemblers for the Amiga follow, to one degree or
  4255. another the Motorola standard. While the instructions themselves  are
  4256. thankfully standard,  the syntax rules for labels,  comments  and
  4257. directives can,  and do,  vary.  This Appendix covers the changes
  4258. most  likely  to be made when converting  programs  from  another
  4259. assembler,  whether  they are your old source files or a  program
  4260. listed  in  a  magazine.  It  does  not  attempt  to  detail  the
  4261. differences  in user interfaces or options between the  different
  4262. assemblers.
  4263.  
  4264. AMIGA MACRO ASSEMBLER AND MCC ASSEMBLER:
  4265.      Almost all source code written for assembly under the Amigados
  4266. Macro Assembler supplied by Commodore and the Metacomco (MCC)
  4267. assembler should assemble with little or no change under GenAm. The
  4268. differances are:
  4269.  
  4270. 1. With GenAm, importing constants using XREF and then accessing them
  4271. as constants (as opposed to relative addresses) may cause warning
  4272. messages. Many source programs use XREFs for _LVO labels. To remove
  4273. these warnings either:
  4274.  
  4275. change XREF to XREF.l
  4276. use OPT W- to supress all warnings
  4277. use OPT T- to suppress type-checking
  4278. include the relevant _lib.l file and remove the XREF
  4279.  
  4280. 2. The directive RORG is not supported. The include files with the
  4281. AmigaDOS Macro Assembler will assemble unchanged by GenAm, but our
  4282. supplied ones are preferred because they use directives instead of
  4283. macro calls to define labels and have comments removed to take less
  4284. disk space and be faster to assemble. The original versions can be
  4285. found in Appendix E of ROM Kernal Manual Volume 2 and on DEVPAC disk
  4286. 2.
  4287.  
  4288. K-SEKA:
  4289.      Colons are not required after labels in GenAm though instructions
  4290. or directives that start in the label field will need a tab added
  4291. before them.  Several Seka directives default to Byte instead  of
  4292. Word sizes for some reason. Equivalent directives names are:
  4293.  
  4294. D=DC,  BLK=DS,  IF=IFNE,  ELSE=ELSEIF, ENDIF=ENDC.
  4295.  
  4296. Macro syntax requires ?s to be changed to \s, except ?0 which should
  4297. be replaced with \@.
  4298.  
  4299. NEW COMMODORE INCLUDE FILES
  4300.      Should you obtain new include files from Commodore you should be
  4301. able to assemble them unchanged with GenAm. however should you wish to
  4302. convert them to the same form as those supplied by us so that they
  4303. take less disk space, and assemble faster, we have supplied two tools
  4304. to convert them for you, 'convertFD' and 'convertI'
  4305.  
  4306. CONVERTI DETAILS:
  4307.      Converti is supplied on disk 2 and converts Commodore include
  4308. files to the same compressed form that we supply. The commandline is
  4309. of the form:
  4310.  
  4311. ConvertI (source) (destination) <-d>
  4312.  
  4313.      The source and destination file names should have their extension
  4314. omitted. Teh -d flag indicates that a whole directory is to be
  4315. converted. For example:
  4316.  
  4317. ConvertI old/dos new/dos
  4318.  
  4319. converts the single file old/dos.i to new/dos.i
  4320.  
  4321. ConvertI old new -d
  4322.  
  4323. will convert all the standard files in the directory old (of course
  4324. they must be there first) to the corresponding name in the directory
  4325. new.
  4326.  
  4327. CONVERTFD DETAILS:
  4328.      ConvertFD is supplied on disk 2 and converts Commodore FD files
  4329. into library files with extension _lib.i containing the_LVO offsets
  4330. for inclusion into your programs.
  4331.      The command-line is of the form:
  4332.  
  4333. ConvertFD (source) (destination) <-d)
  4334.  
  4335.      The source and destination file names should have their
  4336. extensions onitted. The -d flag indicates that a whole directory is to
  4337. be converted. For example:
  4338.  
  4339. ConvertFD fdfiles/dos new/dos
  4340.  
  4341. converts the single file fdfiles/dos_lib.fd to new/dos_lib.i
  4342.  
  4343. ConvertFD fdfiles :include/libraries -d
  4344.  
  4345. will convert all the fd files in the directory fdfiles (of coures they
  4346. must be there first) to the corrosponding include file in the
  4347. directory :include/libraries.
  4348.  
  4349. APPENDIX F: VERSION 2 IMPROVEMENTS
  4350.      All information is already documented earlier.
  4351.  
  4352. APPENDIX G: BIBLIOGRAPHY
  4353.      This bibliography contains our suggestions for further reading on
  4354. the subject of the 68000 and the Amiga.  The views expressed
  4355. are  our  own  and  as  with all  reference  books  there  is  no
  4356. substitute  for  looking at the books in a good  bookshop  before
  4357. making a decision.
  4358.  
  4359. M68000 Programmer's Reference Manual
  4360. Published by Prentice-Hall
  4361. The definitive guide to the instruction set produced by Motorola.
  4362. the  supplied Pocket Guide is a subset of this book.  Be sure  to
  4363. get the latest version - at the time of writing the Fifth Edition
  4364. is the latest.
  4365.  
  4366. 68000 Assembly Language Programming by Kane, Hawkins & Leventhal
  4367. Published by Osborne/McGraw-Hill
  4368. This  is  large  (and expensive) but  good,  containing  lots  of
  4369. examples.  Be  sure to get the second edition.  Not for  complete
  4370. beginners to microprocessors.
  4371.  
  4372. 68000 Tricks and Traps by Mike Morton
  4373. BYTE magazine, September 1986 issue
  4374. By  far the best article on 68000 programming we have ever  seen.
  4375. We wish there was a book like this.
  4376.  
  4377. M68000 Cross Macro Assembler Reference Manual
  4378. Published by Motorola (M68KXASM)
  4379. The  official  definition of 68000  assembly-language  syntax  on
  4380. which Genam is based.
  4381.  
  4382. APPENDIX H: TECHNICAL SUPPORT AND UPGRADES
  4383.       Which is no use to you as your not a registered user!.
  4384.